fix: restore 1min market data payload
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// @version=5
|
||||
// @version=6
|
||||
indicator("1-Minute Market Data Feed", overlay=false)
|
||||
|
||||
// ============================================================================
|
||||
@@ -9,13 +9,13 @@ indicator("1-Minute Market Data Feed", overlay=false)
|
||||
|
||||
// Calculate indicators
|
||||
atr = ta.atr(14)
|
||||
adx = ta.dmi(14, 14)
|
||||
[diPlus, diMinus, adxVal] = ta.dmi(14, 14)
|
||||
rsi = ta.rsi(close, 14)
|
||||
volumeRatio = volume / ta.sma(volume, 20)
|
||||
pricePosition = (close - ta.lowest(low, 100)) / (ta.highest(high, 100) - ta.lowest(low, 100)) * 100
|
||||
|
||||
// Plot for visual confirmation (optional)
|
||||
plot(adx, title="ADX", color=color.blue, linewidth=2)
|
||||
plot(adxVal, title="ADX", color=color.blue, linewidth=2)
|
||||
hline(20, "ADX 20", color=color.orange, linestyle=hline.style_dotted)
|
||||
hline(25, "ADX 25", color=color.red, linestyle=hline.style_dotted)
|
||||
|
||||
@@ -26,8 +26,8 @@ if barstate.islast
|
||||
table.cell(infoTable, 1, 0, "Value", bgcolor=color.new(color.gray, 70), text_color=color.white)
|
||||
|
||||
table.cell(infoTable, 0, 1, "ADX", text_color=color.white)
|
||||
table.cell(infoTable, 1, 1, str.tostring(adx, "#.##"),
|
||||
bgcolor=adx > 25 ? color.new(color.green, 80) : adx > 20 ? color.new(color.orange, 80) : color.new(color.red, 80),
|
||||
table.cell(infoTable, 1, 1, str.tostring(adxVal, "#.##"),
|
||||
bgcolor=adxVal > 25 ? color.new(color.green, 80) : adxVal > 20 ? color.new(color.orange, 80) : color.new(color.red, 80),
|
||||
text_color=color.white)
|
||||
|
||||
table.cell(infoTable, 0, 2, "ATR", text_color=color.white)
|
||||
@@ -46,15 +46,16 @@ if barstate.islast
|
||||
table.cell(infoTable, 0, 5, "Price Pos", text_color=color.white)
|
||||
table.cell(infoTable, 1, 5, str.tostring(pricePosition, "#.#") + "%", text_color=color.white)
|
||||
|
||||
// Alert condition: Fire every bar close (1 minute)
|
||||
// This sends data regardless of market conditions
|
||||
alertcondition(true, title="1min Market Data", message=
|
||||
'{' +
|
||||
// Alert condition to allow creating the alert in TradingView UI
|
||||
alertcondition(true, title="1min Market Data")
|
||||
|
||||
// Build dynamic payload and emit an alert once per bar close
|
||||
alertPayload = '{' +
|
||||
'"action": "market_data_1min",' +
|
||||
'"symbol": "{{ticker}}",' +
|
||||
'"timeframe": "1",' +
|
||||
'"atr": ' + str.tostring(atr, "#.########") + ',' +
|
||||
'"adx": ' + str.tostring(adx, "#.########") + ',' +
|
||||
'"adx": ' + str.tostring(adxVal, "#.########") + ',' +
|
||||
'"rsi": ' + str.tostring(rsi, "#.########") + ',' +
|
||||
'"volumeRatio": ' + str.tostring(volumeRatio, "#.########") + ',' +
|
||||
'"pricePosition": ' + str.tostring(pricePosition, "#.########") + ',' +
|
||||
@@ -62,7 +63,10 @@ alertcondition(true, title="1min Market Data", message=
|
||||
'"timestamp": "{{timenow}}",' +
|
||||
'"exchange": "{{exchange}}",' +
|
||||
'"indicatorVersion": "v9"' +
|
||||
'}')
|
||||
'}'
|
||||
|
||||
if barstate.isconfirmed
|
||||
alert(alertPayload, alert.freq_once_per_bar_close)
|
||||
|
||||
// ============================================================================
|
||||
// ALERT SETUP INSTRUCTIONS:
|
||||
|
||||
Reference in New Issue
Block a user