TradingView webhook JSON
What JSON format does TradingView use for webhook alerts?
TradingView posts the alert message body to your webhook URL as written. Nyria reads the fields action, instrument, direction and legs. Strategy scripts have {{strategy.*}} placeholders TradingView fills on every fill. Indicator scripts have none, so the side goes in the message directly, one alert per side.
Strategy alerts
A strategy fires one alert per fill and fills the strategy placeholders before sending. Nyria works out the direction from the position change: buy into long after flat means OPEN LONG, sell to flat after long means CLOSE LONG.
Strategy JSON (recommended)
{
"action": "{{strategy.order.action}}",
"instrument": "{{ticker}}",
"marketPosition": "{{strategy.market_position}}",
"prevMarketPosition": "{{strategy.prev_market_position}}",
"contracts": "{{strategy.order.contracts}}",
"price": {{close}}
}Strategy plain text
{{strategy.order.action}} {{ticker}} @ {{close}}TradingView default strategy message (also works)
order {{strategy.order.action}} @ {{strategy.order.contracts}} filled on {{ticker}}. New strategy position is {{strategy.position_size}}| Field | Value | Notes |
|---|---|---|
| action | buy / sell | From {{strategy.order.action}} |
| marketPosition | long / short / flat | Position after this fill |
| prevMarketPosition | long / short / flat | Position before this fill |
| price | number, no quotes | TradingView fills {{close}} before sending |
Indicator alerts
Indicator scripts have no strategy context. Create one alert per side and write the direction directly in the message.
Long entry
{ "action": "OPEN", "instrument": "{{ticker}}", "direction": "LONG" }Long exit
{ "action": "CLOSE", "instrument": "{{ticker}}", "direction": "LONG" }Short entry
{ "action": "OPEN", "instrument": "{{ticker}}", "direction": "SHORT" }Short exit
{ "action": "CLOSE", "instrument": "{{ticker}}", "direction": "SHORT" }Limit order (indicator)
{ "action": "OPEN", "instrument": "{{ticker}}", "direction": "LONG", "order_type": "limit", "price": {{close}} }Options: contract from strategy rules
When the strategy picks the contract by its own delta and DTE rules, the alert names the ticker and direction. The strategy handles strike, expiration and side.
Entry
{ "action": "OPEN", "instrument": "{{ticker}}", "direction": "LONG" }Exit
{ "action": "CLOSE", "instrument": "{{ticker}}", "direction": "LONG" }Options: contract named in the alert
Add a legs array to specify the strike, expiration and side. Nyria trades up to 4 legs per order on one expiration.
Single-leg call entry
{
"action": "OPEN",
"instrument": "{{ticker}}",
"direction": "LONG",
"legs": [
{ "side": "CALL", "strike": 780, "expiration": "2026-12-18", "action": "buy_to_open" }
]
}Bull call spread (2 legs)
{
"action": "OPEN",
"instrument": "{{ticker}}",
"direction": "LONG",
"legs": [
{ "side": "CALL", "strike": 780, "expiration": "2026-12-18", "action": "buy_to_open" },
{ "side": "CALL", "strike": 785, "expiration": "2026-12-18", "action": "sell_to_open" }
]
}Single-leg put entry
{
"action": "OPEN",
"instrument": "{{ticker}}",
"direction": "SHORT",
"legs": [
{ "side": "PUT", "strike": 780, "expiration": "2026-12-18", "action": "buy_to_open" }
]
}Exit (closes any position)
{
"action": "CLOSE",
"instrument": "{{ticker}}",
"direction": "LONG"
}| Field | Values | Notes |
|---|---|---|
| side | CALL / PUT | Case-insensitive |
| strike | number | No dollar sign |
| expiration | YYYY-MM-DD | Must be a listed expiration date |
| action | buy_to_open / sell_to_open | One value per leg |
Crypto alerts
Crypto uses the same shape as stocks. Open the alert on a crypto chart so {{ticker}} resolves to the pair.
Crypto entry
{ "action": "OPEN", "instrument": "{{ticker}}", "direction": "LONG" }Crypto exit
{ "action": "CLOSE", "instrument": "{{ticker}}", "direction": "LONG" }Common mistakes
- Strategy placeholders in an indicator alert:
{{strategy.order.action}}arrives as typed text when sent from an indicator. Write OPEN or CLOSE directly. - Missing 2FA or paid plan: TradingView requires both to deliver webhook alerts. The free plan can create alerts but not send them.
- Quoting the price field:
{{close}}is a number after TradingView fills it. Leave it unquoted. - Wrong ticker for crypto: open the alert on a crypto chart (BTCUSD, ETHUSD) so
{{ticker}}resolves to the crypto pair, not a stock symbol.
Test your message
Paste any of these into the alert tester to see the order Nyria would place, or use the TradingView alert message builder to build and check a message before adding it to your alert.
Questions
- Does the price field in JSON need quotes?
- No. Writing "price": {{close}} without quotes is correct. TradingView fills {{close}} with a number before sending, so the result is valid JSON. Quoting it gives a string, which Nyria also accepts, but a number is cleaner.
- Why does my indicator alert send the literal text {{strategy.market_position}}?
- Indicator scripts have no strategy context. The {{strategy.*}} placeholders are filled only when a strategy fires the alert. In an indicator, write the direction directly: LONG or SHORT, OPEN or CLOSE.
- Do I need a paid TradingView plan to send webhooks?
- Yes. TradingView requires a paid plan and two-factor authentication to deliver webhook alerts. The free plan can create alerts but cannot send them to a URL.
- Can I use the same JSON for stocks, options and crypto?
- Yes, for simple entries and exits. Add a legs array to name the options contract in the alert. For crypto, open the alert on a crypto chart so {{ticker}} resolves to the pair.
Run your TradingView alerts on a free paper bot
Trade and test free on paper, forever. No card required.