Loading page…
Loading page…
3-step interactive decision tree and broken-vs-fixed code diffs for TradingView indicator alerts, strategy alert_message, and bots.
Select your script type, message complexity, and delivery target to get the only non-failing Pine v6 alert architecture.
Fires strictly when TradingView's strategy engine actually executes an order fill (entry, exit, TP, or SL), guaranteeing webhook parity with Strategy Tester.
Order fills only ignores standalone alert() calls; selecting Any alert() function call ignores strategy.entry(alert_message).1//@version=62strategy("Verified Strategy Alert Engine", overlay = true, process_orders_on_close = false)3 4fast = ta.ema(close, 21)5slow = ta.ema(close, 55)6longCond = ta.crossover(fast, slow) and strategy.position_size == 07 8if longCond9 string msg = '{"action":"buy","ticker":"' + syminfo.ticker + '","price":' + str.tostring(close) + ',"atr":' + str.tostring(ta.atr(14), "#.##") + '}'10 strategy.entry("Long", strategy.long, alert_message = msg)11 12if strategy.position_size > 013 string exitMsg = '{"action":"close","ticker":"' + syminfo.ticker + '","price":' + str.tostring(close) + '}'14 strategy.exit("ExitLong", from_entry = "Long", stop = strategy.position_avg_price * 0.985, limit = strategy.position_avg_price * 1.03, alert_message = exitMsg)15 16plot(fast, "EMA 21", color = color.new(#2962ff, 0))17plot(slow, "EMA 55", color = color.new(#ff9800, 0))1//@version=62strategy("Silent Alert Bug", overlay = true)3longCond = ta.crossover(ta.ema(close, 9), ta.ema(close, 21))4if longCond5 strategy.entry("Long", strategy.long)6 7// BUG: alertcondition() cannot fire strategy fills8alertcondition(longCond, title = "Buy", message = '{"action":"buy"}')1//@version=62strategy("Verified Strategy Webhook", overlay = true)3longCond = ta.crossover(ta.ema(close, 9), ta.ema(close, 21))4if longCond5 // FIX: Attach JSON payload to strategy.entry() and put6 // {{strategy.order.alert_message}} in the TV Alert Message box7 string payload = '{"action":"buy","ticker":"' + syminfo.ticker + '"}'8 strategy.entry("Long", strategy.long, alert_message = payload)1//@version=62indicator("Broken Dynamic alertcondition", overlay = true)3rsiVal = ta.rsi(close, 14)4cond = ta.crossover(rsiVal, 30)5 6// BUG: str.tostring(rsiVal) produces a 'series string'7alertcondition(cond, "Oversold", "RSI crossed 30: " + str.tostring(rsiVal))1//@version=62indicator("Fixed Dynamic alert()", overlay = true)3rsiVal = ta.rsi(close, 14)4cond = ta.crossover(rsiVal, 30)5 6// FIX: alert() accepts runtime series strings; select "Any alert() function call"7if cond and barstate.isconfirmed8 alert("RSI crossed 30: " + str.tostring(rsiVal, "#.##"), alert.freq_once_per_bar_close)| Capability | Runtime Behavior & Trade-Off | API Support | Copy |
|---|---|---|---|
| Works in strategy() scripts | alertcondition() is silently ignored in strategies. Use strategy.*(alert_message) or alert() instead. | alert(): Yes | alertcondition(): No | alert_message: Yes | |
| Dynamic series string messages | alert() and strategy alert_message accept runtime str.tostring(close/atr). alertcondition() strictly requires const string. | alert(): series string | alertcondition(): const string only | |
| Multiple signals in 1 cloud alert | One 'Any alert() function call' alert can multiplex 40 tickers or 10 entry/exit signals; alertcondition() needs 1 alert per condition. | alert(): Unlimited in 1 slot | alertcondition(): 1 per slot | |
| Synced with broker order fills | Only strategy.entry/exit/close(alert_message) guarantees parity with Strategy Tester fills, pyramiding, and stop-loss hits. | Order fills only -> {{strategy.order.alert_message}} | |
| End-user editable in TV UI dialog | alertcondition() lets chart users override the message template in TradingView UI without modifying Pine code. | alertcondition(): Editable | alert(): Hardcoded in Pine | |
| Trigger frequency control | alert() controls frequency in code (alert.freq_once_per_bar_close). alertcondition() relies on manual UI dropdown selection. | Prefer barstate.isconfirmed + freq_once_per_bar_close |
Order fills only suppresses all standalone alert() calls, while alert() function calls only suppresses strategy.entry(alert_message). Pick Order fills and alert() function calls only when you intentionally use both.alert.freq_once_per_bar_close delays delivery until bar close, combining it with and barstate.isconfirmed prevents side-effect state mutations (like counters or JSON buffers) from running mid-bar.