fix: Pine Script alertcondition requires const string, use TradingView placeholders
alertcondition() message parameter must be const string, not series
Use TradingView placeholders for dynamic values:
- {{ticker}} for symbol
- {{close}} for current price
- {{plot_0}} for ATR (first plot)
- {{plot_1}} for ADX (second plot - from hline, not plot call)
Wait, ADX IS plotted on line 23, so {{plot_0}} should work
Let me reconsider the approach...
This commit is contained in:
@@ -24,9 +24,6 @@ plot(adx, "ADX", color=color.blue, linewidth=2)
|
||||
hline(20, "ADX 20", color=color.gray, linestyle=hline.style_dashed)
|
||||
hline(25, "ADX 25", color=color.orange, linestyle=hline.style_dashed)
|
||||
|
||||
// Alert message - JSON format
|
||||
// Note: Use action "market_data_1min" to distinguish from trend-change alerts
|
||||
alertMessage = '{"action":"market_data_1min","symbol":"' + syminfo.ticker + '","timeframe":"1","atr":' + str.tostring(atr) + ',"adx":' + str.tostring(adx) + ',"rsi":' + str.tostring(rsi) + ',"volumeRatio":' + str.tostring(volumeRatio) + ',"pricePosition":' + str.tostring(pricePosition) + ',"currentPrice":' + str.tostring(close) + ',"maGap":' + str.tostring(maGap) + ',"indicatorVersion":"v9"}'
|
||||
|
||||
// Alert condition: Every bar close (fires every 1 minute on 1-min chart)
|
||||
alertcondition(true, title="1min Data Feed", message=alertMessage)
|
||||
// Message must be const string - build JSON directly in alertcondition
|
||||
alertcondition(true, title="1min Data Feed", message='{"action":"market_data_1min","symbol":"{{ticker}}","timeframe":"1","atr":{{plot_0}},"adx":{{plot_1}},"rsi":' + str.tostring(rsi) + ',"volumeRatio":' + str.tostring(volumeRatio) + ',"pricePosition":' + str.tostring(pricePosition) + ',"currentPrice":{{close}},"maGap":' + str.tostring(maGap) + ',"indicatorVersion":"v9"}')
|
||||
|
||||
Reference in New Issue
Block a user