Blog · TradingView · Article · updated 2026-09-25
alertcondition() vs alert() vs strategy alerts in TradingView
The three ways a TradingView script can trigger alerts, how each behaves, which one to choose for automation, and how the TensorTrader extension detects them.
Key takeaways
- 1alertcondition(): named conditions, one alert per condition, predictable.
- 2alert(): script-built messages, one alert catches every call, saves quota.
- 3Strategy alerts: one alert per token covers entries, exits and reversals.
- 4Use bar-close frequency for any alert that places orders.
Three mechanisms
- alertcondition()
- The script declares named conditions ("Long entry", "Short entry"). You create one alert per condition.
- alert()
- The script calls alert() in its logic with a message it builds. One alert on "Any alert() function call" receives every call.
- strategy alerts
- A Pine strategy fires an alert on each simulated order fill; {{strategy.order.action}} says buy or sell.
alertcondition(): simple and explicit
alertcondition() is the classic indicator approach. The author names conditions, and you pick one when creating the alert. It is predictable: one condition, one alert, one action. The limitation is that conditions are fixed at compile time and the message cannot be computed dynamically; you write it in the alert dialog. For automation that is usually fine, because the webhook message only needs to identify the action.
In the TensorTrader extension this is the "Indicator condition (per-direction)" mechanism. Batch Create makes one alert per direction per token, and Variable alignment maps each action (open long, open short) to one of the script's conditions, marked with a diamond.
alert(): flexible, one alert for everything
alert() lets a script raise alerts from anywhere in its code with messages it builds itself, including computed values. One TradingView alert set to "Any alert() function call" catches all of them, which saves quota. The trade-off is that the script decides the message, so it must produce something your executor understands. It is also the fallback when a script's alertconditions fail with study_error: the extension suggests switching to this mechanism.
Strategy alerts: exits included
A Pine strategy simulates orders, and a strategy alert fires on each simulated fill. Because the strategy owns both entries and exits, one alert per token covers the whole lifecycle, and {{strategy.order.action}} plus {{strategy.market_position}} tell the executor what happened. TensorTrader uses the strategy_v6 message template for these, and the Strategy Properties card sets initial capital, order size, pyramiding and run mode so the alert's simulation matches your sizing.
Which one to choose
- 1You want exits handled by the script and one alert per token: use a strategy.
- 2You use an indicator with clear long and short conditions: use alertcondition() per direction.
- 3The script only calls alert(), or alertconditions fail: use "Any alert() function call".
- 4You want several indicators to agree before entering: combine alertconditions into a multi-condition alert.
How the extension detects the mechanism
When you pick a favorite in step 3, the extension inspects it: strategies get "Strategy orders", scripts that expose alertconditions get "Indicator condition (per-direction)", and scripts that only use alert() get "Any alert() function call". You can override the choice in the Alert mechanism dropdown; it shows "(auto-detected)" until you do.
A minimal example of each
Use once-per-bar-close frequency for automation. Intrabar alerts can fire on a condition that disappears before the bar closes, which is a common source of phantom trades.
// alertcondition(): one alert per condition
alertcondition(ta.crossover(fast, slow), "Long entry", "long")
alertcondition(ta.crossunder(fast, slow), "Short entry", "short")
// alert(): the script builds the message
if ta.crossover(fast, slow)
alert("long " + syminfo.ticker, alert.freq_once_per_bar_close)Frequently asked questions
- Can one script have both alertcondition() and alert()?
- Yes. Pick the mechanism that matches how you want alerts delivered; the extension auto-detects a sensible default.
- Which uses fewer alerts?
- Strategies and alert() use one alert per token and timeframe; per-direction alertconditions use two.
- Why does my alertcondition not appear in the alert dialog?
- The script must be added to the chart and the condition declared at the script’s top level; conditions inside local scopes are not exposed.
- Which mechanism is fastest?
- All fire on the same bar close when set to once per bar close; speed differences come from the bar, not the mechanism.
Keep reading
TradingView webhook automation: from alert to exchange order
Everything about automating TradingView: alert types, webhook JSON, plan limits, building hundreds of alerts with the Chrome extension, managing them, and executing on 30 exchanges and brokers, paper first.
Pine strategy alerts: {{strategy.order.action}} and friends explained
How TradingView strategy alerts fire, what {{strategy.order.action}} and {{strategy.market_position}} contain, and how to automate a Pine strategy with correct sizing.
TradingView study_error and alert rate limits: causes and fixes
Why TradingView alerts end up in study_error, how rate limits affect bulk alert creation, and how the TensorTrader extension detects both and stops safely.
TradingView multi-condition alerts: combine up to 5 indicators with AND
How to require several indicators to agree before an automated entry, using TradingView multi-condition alerts built by the TensorTrader extension.
Not financial advice. Performance figures are TensorTrader testnet or backtest results with the method stated; past results do not predict future returns.