Skip to content

TradingView webhook JSON

What JSON format does TradingView use for webhook alerts?

TradingView sends the alert message as JSON with action (buy or sell), ticker and an optional price. Nyria reads those fields and places the order. A strategy script fills {{strategy.order.action}} and {{ticker}} automatically; an indicator alert writes the action directly. Test any message on Nyria Paper first.

Minimal webhook JSON

{
  "action": "{{strategy.order.action}}",
  "ticker": "{{ticker}}"
}

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}}",
  "ticker": "{{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}}
FieldValueNotes
actionbuy / sellFrom {{strategy.order.action}}
marketPositionlong / short / flatPosition after this fill
prevMarketPositionlong / short / flatPosition before this fill
pricenumber, no quotesTradingView 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", "ticker": "{{ticker}}", "direction": "LONG" }

Long exit

{ "action": "CLOSE", "ticker": "{{ticker}}", "direction": "LONG" }

Short entry

{ "action": "OPEN", "ticker": "{{ticker}}", "direction": "SHORT" }

Short exit

{ "action": "CLOSE", "ticker": "{{ticker}}", "direction": "SHORT" }

Limit order (indicator)

{ "action": "OPEN", "ticker": "{{ticker}}", "direction": "LONG", "order_type": "limit", "price": {{close}} }

Options: contract from your rules

The alert says open or close, and long or short. The strategy's option rules pick call or put, strike, expiry and legs.

Long entry

{ "action": "OPEN", "ticker": "{{ticker}}", "direction": "LONG" }

Long exit

{ "action": "CLOSE", "ticker": "{{ticker}}", "direction": "LONG" }

Short entry

{ "action": "OPEN", "ticker": "{{ticker}}", "direction": "SHORT" }

Short exit

{ "action": "CLOSE", "ticker": "{{ticker}}", "direction": "SHORT" }
AlertUsesNew strategy default
OPEN LONGYour long entry legsBuy a call
OPEN SHORTYour short entry legsBuy a put
CLOSEThe open position on that sideCloses what it opened

A spread strategy builds every leg from its leg rules. It prices the order at your price. A TradingView alert carries no strike, expiration or legs. Nyria drops any it is sent. To name each leg, send from your own bot or script. Set the strategy to Provided in alert.

Naming the contract

A TradingView strategy always uses From my rules. Strike, expiry and legs in a TradingView alert are ignored.

Alerts that name the contract need a strategy set to Provided in alert. That works with Discord, Telegram, TrendSpider and your own bot. See the options alert message templates.

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", "ticker": "{{ticker}}", "direction": "LONG" }

Crypto exit

{ "action": "CLOSE", "ticker": "{{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. Every alert field is in the webhook reference.

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. On options, the strategy's rules pick the contract. 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. No card required.