Skip to content

Guide

TradingView webhook JSON format

TradingView needs no fixed JSON format. A buy alert can be {"action": "OPEN", "ticker": "{{ticker}}", "direction": "LONG"}. The matching sell swaps OPEN for CLOSE. TradingView posts valid JSON as application/json and anything else as text/plain. Nyria reads either, in your own wording. The message names the ticker, the side, and open or close. A body as short as AAPL long entry works.

Official documentation

Write and check a webhook message

  1. 1

    Start with three fields

    The ticker, the side, and whether the alert opens or closes a position. Plain text such as AAPL long entry says all three.

  2. 2

    Use placeholders for what changes

    TradingView fills in placeholders such as {{ticker}} and {{strategy.order.action}} before it sends the alert, so one alert can serve every symbol a chart is on.

  3. 3

    Paste the message in the alert

    In the alert dialog open Message, paste it over the text there and select Apply. Open Notifications, tick Webhook URL, paste the strategy's URL and select Apply.

  4. 4

    Test it before it trades

    Paste the message into the alert tester to see the ticker and side Nyria reads, then select Check format on the strategy. The Logs tab shows what each live alert was read as.

Watch the setup

How to automate TradingView alerts to your broker (free paper account first)
Start on free Nyria Paper and build a TradingView strategy. Check the alert format, deploy a bot.
Steps in the video
  1. 0:00Pick Nyria Paper or a broker. Open Integrations. Nyria Paper is free and needs no broker, so start there. Charles Schwab, Tradier and tastytrade connect through their own sign-in, and Alpaca takes an API key.
  2. 0:58Create a strategy. Select Create strategy and name it. Then, select your alert source. This example uses TradingView. Pick stocks and a ticker, then create the draft.
  3. 1:28Create the alert in TradingView. Copy the webhook URL and the alert message from the Integration tab. In TradingView, select Message, paste the message and select Apply. Then select Notifications, tick Webhook URL, paste the URL and select Apply.
  4. 3:13Check the format. Select Check format and add an entry and an exit alert. Nyria shows the ticker, side and order it read.
  5. 3:32Deploy a bot. Select Deploy bot, set a budget per entry and pick an account. Nyria Paper is free, so test there first. On a live broker account, pick it on the Account step. Send a sample alert and watch the paper order fill.

Messages to copy

Buy, long entry

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

Sell, long exit

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

Plain text

SPY long entry

JSON with TradingView placeholders

{
  "ticker": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "marketPosition": "{{strategy.market_position}}",
  "prevMarketPosition": "{{strategy.prev_market_position}}"
}

An option, as JSON

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

What to know about the message

  • Do not put logins or passwords in a webhook message. TradingView warns against it.
  • The message cannot set the size. The bot sizes each order from its Budget per entry.
  • An option alert names the ticker and direction. The strategy's rules pick the contract. LONG uses the call rule, SHORT the put rule.
  • An identical alert body that repeats straight after the first is dropped, so a double send does not open two positions.

Questions

What's a TradingView webhook JSON example for buy and sell?
Buy: {"action": "OPEN", "ticker": "{{ticker}}", "direction": "LONG"}. Sell: the same with "action": "CLOSE". A strategy alert can send {{strategy.order.action}}, which TradingView fills with buy or sell.
Does a TradingView webhook have to be JSON?
No. TradingView sends plain text as text/plain and valid JSON as application/json, and Nyria reads both.
Is there a required JSON template for Nyria?
No. Name the ticker and the side in your own wording. The message Nyria shows on the Integration tab works as it is, and a message you already use can stay.
Where can I try a message before it trades?
In the alert tester and the alert builder. Both are free and need no broker.
What does it cost?
Paper is free. Live trading from $15 a month.

Next

Try a paper bot first

No card required. Paper is free. Live trading from $15 a month.