BotEdge

TradingView webhook message format: JSON and placeholders explained

By the BotEdge team · · 8 min read

Short answer

A TradingView webhook is an HTTP POST whose body is your alert message. Write the message as valid JSON and TradingView sends it as application/json; put placeholders such as {{strategy.order.action}} inside it and TradingView fills them in when the alert fires. For BotEdge, the message needs your pointer, the ticker, the action and the quantity.

Key facts

  • The webhook body is exactly the text in the alert's Message box, after placeholders are replaced.
  • Valid JSON is sent as application/json; anything else is sent as text/plain.
  • TradingView cancels a webhook request that takes longer than three seconds, and only sends webhooks from accounts with two-factor authentication.
  • {{strategy.order.action}} becomes buy or sell; {{strategy.order.contracts}} becomes the order size the strategy executed.
  • One invalid character, such as a curly quote or a trailing comma, turns the whole message into plain text that an execution service cannot read.

What TradingView sends to a webhook

When an alert fires and Webhook URL is ticked in its notifications, TradingView makes an HTTP POST request to that URL. The request body is the alert message, with every placeholder already replaced by its value at that moment.

  • If the message is valid JSON, the request has the header Content-Type: application/json. Otherwise it is text/plain.
  • URLs with an explicit port must use 80 or 443; other ports are refused.
  • The receiving server has three seconds to answer, or TradingView cancels the request.
  • Webhooks are only sent from accounts with two-factor authentication turned on, and they need a TradingView plan that includes webhook notifications.

The BotEdge alert message, field by field

BotEdge reads a small JSON object. Four fields cover most strategies; the others are optional. The full reference is in the TradingView alerts docs.

FieldRequiredValueWhat it does
pointerYesYour connection's 20-character pointerPicks the exchange account that places the order
tickerYes{{ticker}} or a symbol such as BTCUSDTThe market. .P and PERP suffixes are ignored
actionUnless closeallbuy or sellThe order side
quantityFor ordersA number such as 0.01The order size, in the unit the exchange uses
prev_positionNoflat, long or shortMakes closing orders reduce-only on Binance futures, Bybit, Bitget, BitMart Futures and Hyperliquid
closeallNo"true"Closes the open position on the ticker instead of placing an order
type and priceNolimit and a pricePlaces a limit order instead of a market order
takeprofit, stoplossNoPricesAttaches exits on the exchanges that support them

Placeholders that fill the message

TradingView replaces any {{...}} variable it knows when the alert fires. The ones that matter for automated orders:

PlaceholderBecomesUse it for
{{ticker}}The chart's symbol, for example BTCUSDT.PThe ticker field
{{exchange}}The chart's exchange, for example BYBITChecking you alerted from the right exchange
{{strategy.order.action}}buy or sellThe action field (strategy alerts)
{{strategy.order.contracts}}The size of the order the strategy executedThe quantity field (strategy alerts)
{{strategy.prev_market_position}}flat, long or short before the orderThe prev_position field
{{strategy.market_position}}The position after the orderLogging and checks
{{strategy.order.alert_message}}The alert_message text set in the Pine Script order callA different message per order
{{close}}, {{timenow}}, {{interval}}Price, alert time and timeframeYour own records

Good to know

Strategy placeholders only exist in alerts created on a strategy. In an indicator or manual alert, write the side and size yourself.

Ready-made messages you can copy

Strategy alert (the one your BotEdge connection card gives you, with your pointer in it). Create the alert on the strategy with "Order fills only":

{
  "pointer": "YOUR_POINTER_HERE___",
  "ticker": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "prev_position": "{{strategy.prev_market_position}}"
}

Indicator or manual alert, one alert to buy and one to sell:

{
  "pointer": "YOUR_POINTER_HERE___",
  "ticker": "{{ticker}}",
  "action": "buy",
  "quantity": "0.01"
}
{
  "pointer": "YOUR_POINTER_HERE___",
  "ticker": "{{ticker}}",
  "action": "sell",
  "quantity": "0.01"
}

Close the whole position on the ticker, whatever its size and side:

{
  "pointer": "YOUR_POINTER_HERE___",
  "ticker": "{{ticker}}",
  "closeall": "true"
}

Limit order with take-profit and stop-loss, on an exchange that supports them:

{
  "pointer": "YOUR_POINTER_HERE___",
  "ticker": "BTCUSDT",
  "action": "buy",
  "quantity": "0.01",
  "type": "limit",
  "price": "60000",
  "takeprofit": "66000",
  "stoploss": "57000"
}

Advanced: a different message for each order

A strategy can attach its own text to each order with the alert_message argument of strategy.entry, strategy.exit, strategy.order or strategy.close. Put only {{strategy.order.alert_message}} in the alert's Message box, and every fill sends the text that order carried:

strategy.entry("Long", strategy.long, alert_message = '{"pointer": "YOUR_POINTER_HERE___", "ticker": "BTCUSDT", "action": "buy", "quantity": "0.01", "takeprofit": "66000"}')

This is useful when entries and exits need different fields, for example a take-profit on the entry only. Keep the pointer out of scripts you share: anyone holding it can trigger orders.

Mistakes that break the message

MistakeWhat happensFix
Curly quotes (“ ”) from a notes app or chatThe message is not JSON any more and arrives as plain textType straight quotes (") or paste the message from your dashboard
A trailing comma after the last fieldInvalid JSONRemove the comma before }
Comments such as // buyInvalid JSON: JSON has no commentsDelete them
closeall sent as true without quotesThe field is not recognized as intendedWrite "closeall": "true"
Alerting from another exchange's chart{{ticker}} names a market your exchange may not listAlert from the chart of the exchange you connected
Alerting from a dated futures chart{{ticker}} sends a contract like BTCUSDZ2026Use the spot or perpetual chart, or write the ticker: "ticker": "BTCUSDT"
Missing or old pointerThe alert reaches no connectionCopy the message again from the connection card

When an order fails anyway, the email you receive and the trading journal in your dashboard give the exchange's reason; the error guide explains the fix.

Frequently asked questions

Does a TradingView webhook message have to be JSON?
TradingView sends any text. Valid JSON is sent as application/json and everything else as text/plain. Execution services such as BotEdge read JSON fields, so the message must be valid JSON for an order to be placed.
What does {{strategy.order.action}} return?
The side of the order the strategy just executed: buy or sell. It only exists in alerts created on a strategy, not on indicators.
Why does my ticker end in .P?
TradingView marks perpetual futures charts with .P, for example BTCUSDT.P. BotEdge ignores the .P and PERP suffixes and uses the matching market on your exchange.
Can I use the same message for several strategies?
Yes. The pointer picks the exchange account and {{ticker}} picks the market, so the same message works on every chart of that exchange. Use a different connection, and so a different pointer, for each account.
Is it safe to put my pointer in the alert message?
The message is only sent to the webhook URL you set, but anyone who sees the pointer can trigger orders. Never post it publicly, and generate a new pointer from the dashboard if it leaks.

Sources