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...
30 lines
1.5 KiB
Plaintext
30 lines
1.5 KiB
Plaintext
//@version=6
|
|
indicator("Money Line - 1min Data Feed", overlay=false)
|
|
|
|
// ==========================================
|
|
// PURPOSE: Send market data every 1 minute
|
|
// USAGE: Create alert with "Once Per Bar Close"
|
|
// WEBHOOK: https://flow.egonetix.de/webhook/tradingview-bot-v4
|
|
// ==========================================
|
|
|
|
// Calculate indicators (same as v9 for consistency)
|
|
atr = ta.atr(14)
|
|
[diPlus, diMinus, adx] = ta.dmi(14, 14) // ADX returns tuple in Pine v5+
|
|
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
|
|
|
|
// Moving averages for MA gap analysis
|
|
ma50 = ta.sma(close, 50)
|
|
ma200 = ta.sma(close, 200)
|
|
maGap = math.abs((ma50 - ma200) / ma200 * 100)
|
|
|
|
// Display values (optional - for visual confirmation)
|
|
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 condition: Every bar close (fires every 1 minute on 1-min chart)
|
|
// 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"}')
|