TradingView alert messages
Copy-ready TradingView alert messages for a strategy or an indicator, every placeholder you can use, and the mistake that stops an alert from trading.
Copy the alert message for your TradingView script from this page. A strategy() script needs one alert per ticker; an indicator() needs one alert per side. For the full setup, see connect TradingView alerts.
A message can be plain text or JSON, and TradingView fills in placeholders
such as {{ticker}} before it sends the alert. The messages below are the
defaults Nyria's setup wizard writes. If you write your own, check it on
the strategy's Integration tab.
The TradingView alert message builder builds and checks one of these for you, free and with no account needed.
Strategy: one "Order fills only" alert
A strategy() script fires an alert on every order it fills, so you create this alert once per ticker:
{
"action": "{{strategy.order.action}}",
"instrument": "{{ticker}}",
"marketPosition": "{{strategy.market_position}}",
"prevMarketPosition": "{{strategy.prev_market_position}}",
"contracts": "{{strategy.order.contracts}}",
"price": {{close}}
}If you run an indicator(), convert it to a strategy and this single alert covers every side.
Indicator: one alert per side
An indicator() needs a separate alert for each side. Indicators have no strategy placeholders, so each message spells out its own action and direction.
Long entry
{
"action": "OPEN",
"instrument": "{{ticker}}",
"direction": "LONG",
"price": {{close}},
"message": "Open long {{ticker}} at {{close}}"
}Long exit
{
"action": "CLOSE",
"instrument": "{{ticker}}",
"direction": "LONG",
"price": {{close}},
"message": "Close long {{ticker}} at {{close}}"
}Short entry
{
"action": "OPEN",
"instrument": "{{ticker}}",
"direction": "SHORT",
"price": {{close}},
"message": "Open short {{ticker}} at {{close}}"
}Short exit
{
"action": "CLOSE",
"instrument": "{{ticker}}",
"direction": "SHORT",
"price": {{close}},
"message": "Close short {{ticker}} at {{close}}"
}Placeholders
TradingView replaces these when the alert fires.
| Placeholder | Becomes | Used by |
|---|---|---|
{{ticker}} | The chart symbol (for example SPY) | both |
{{close}} | Confirmed bar close | both |
{{strategy.order.action}} | buy / sell | strategy |
{{strategy.market_position}} | long / short / flat after the fill | strategy |
{{strategy.prev_market_position}} | Position before the fill | strategy |
{{strategy.order.contracts}} | Order size (reference only; Nyria sizes from your bot) | strategy |
{{interval}} | Chart timeframe | either |
{{time}} / {{timenow}} | Bar open time / alert fire time, UTC | either |
{{exchange}} | Data source (for example NASDAQ) | either |
{{plot_0}}–{{plot_19}} | Numbered plot values from the script | indicator |
TradingView replaces only its own placeholders. A Pine variable such as
{{syminfo.ticker}} reaches Nyria exactly as typed, and nothing trades.
Use {{ticker}} in the alert dialog's Message box, or join
syminfo.ticker into a Pine alert() string, for example
'{"instrument":"' + syminfo.ticker + '"}'.
Next steps
- Connect TradingView alerts: the full setup, including Once per bar close and repainting.
- Convert an indicator to a strategy: replace the per-side alerts with one.
- Webhook reference: every field Nyria reads from the message.
- Alert examples on GitHub: ready-to-paste strategy and indicator messages and a Pine Script alert builder.
Convert a TradingView indicator to a strategy
Turn an indicator() Pine script into a strategy() so one alert covers every entry and exit, instead of one alert per condition per ticker.
Trade alerts from a Discord server you run
Options and stock alerts in a Discord server you run, auto-traded at your broker. Members subscribe and their own bots trade the same calls. Paper is free.