Roboquant
Reference7 min read2026-01-10Updated

TradingView Alert JSON Format: Complete Reference Guide

Reference for TradingView alert JSON when automating Tradovate orders: every field and alias, sizing, stop loss and take profit, placeholders, examples and common mistakes.

Roboquant

Roboquant Team

Trading Automation Experts

tradingviewjsonwebhooksreferenceapi
TradingView Alert JSON Format: Complete Reference Guide

How TradingView Alert Messages Work

When a TradingView alert with a webhook fires, TradingView sends the text of the alert's Message field to your webhook URL. It first replaces any placeholders, such as {{ticker}}, with live values. It does not check, format or fix the text.

TradingView itself does not require JSON. The service that receives the message does. Each service defines its own keys, so a message written for one tool will not work in another. This reference documents the JSON format Roboquant Connect accepts for Tradovate orders, and the TradingView rules that apply to any receiver.

The short version: build your alert in Connect's Alert Builder and copy the JSON it generates. Use this page to understand what the builder produced, or to adjust a message by hand.

The Minimal Message

This is what the Alert Builder generates for a strategy alert on a single Tradovate account:

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "price": "{{strategy.order.price}}"
}

When the strategy buys 2 contracts, TradingView fills in the placeholders and the message arrives with "side": "buy" and "quantity": "2". With the account's position sizing on Fixed Qty (the default), Connect places a market buy for 2 contracts on account 12345678.

For an indicator alert, there is no strategy order to read, so side and quantity are fixed and the price comes from the bar close:

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "buy",
  "quantity": 1,
  "price": "{{close}}"
}

With indicator alerts you create one alert per action, for example one with "side": "buy", one with "side": "sell" and one with "side": "close".

JSON Rules TradingView Won't Check for You

  1. Double quotes only. {'side': 'buy'} is not valid JSON.
  2. Quote placeholders. Write "quantity": "{{strategy.order.contracts}}", not "quantity": {{strategy.order.contracts}}. The quoted form stays valid JSON before and after TradingView fills it in. Connect reads numbers sent as text.
  3. No trailing commas after the last field.
  4. No comments. JSON has no // comments.
  5. Stay within TradingView's size limits. The Message field holds up to 4,000 characters. Messages built in Pine with alert() or alert_message can be up to 40,960 characters (TradingView size limits).

If you edit a message by hand, paste it into any JSON validator before saving the alert.

Field Reference

Most fields accept both camelCase and snake_case, so accountId and account_id mean the same thing.

Order fields

FieldAccepted namesValuesNotes
SymbolsymbolRoot symbol (MNQ) or {{ticker}}Required
Sideside or actionbuy, sell, close, cancel_allCase-insensitive, so Buy works
Quantityquantity, qty or contractsNumber of contractsUse exactly one of the three
Order typeorder_type (snake_case only)market, limit, stopMarket if omitted
PricepricePrice for limit and stop ordersStrategy alerts send {{strategy.order.price}}

What the sides do:

  • buy / sell: open, add to or reduce a position.
  • close: exit the position on that symbol. Exits and close still go through when the daily loss limit has blocked new entries.
  • cancel_all: cancel working orders for that symbol.

Account fields

FieldAccepted namesUse it for
One accountaccountId / account_idA single Tradovate account
Several accountsaccountIds / account_idsThe same order on each account
Accounts with their own sizingaccountsA list of { "accountId", "fixedQuantity" or "quantityMultiplier" }

Every message must name at least one account. A message without accountId, accountIds or accounts does not place an order.

Sizing fields

FieldAccepted namesEffect
MultiplierquantityMultiplier / quantity_multiplierMultiplies the alert's quantity
Fixed quantityfixedQuantity / fixed_quantityIgnores the alert's quantity and trades this size

The multiplier applies when the account's position sizing is Fixed Qty, the default. A fixed quantity always wins.

For one account the Alert Builder puts these at the top level. For several accounts with different sizing it puts them inside each entry of accounts.

Exit fields

FieldAccepted namesValues
Stop lossstopLoss / stop_lossA number
Stop loss unitstopLossType / stop_loss_typeprice, ticks, points, percent
Take profittakeProfit / take_profitA number
Take profit unittakeProfitType / take_profit_typeprice, ticks, points, percent

price is an absolute price. ticks and points are distances from the entry. percent is a percentage of price.

Reversal field

FieldAccepted namesValues
Flatten firstflattenFirst, flatten_first, closePositions, close_positionstrue or false

When true and you hold a position in the opposite direction, Connect adds that position's size to the order, so a single order closes the old position and opens the new one.

Examples

Fixed stop loss and take profit

A strategy entry with a 10-point stop and a 20-point target:

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "price": "{{strategy.order.price}}",
  "stopLoss": 10,
  "stopLossType": "points",
  "takeProfit": 20,
  "takeProfitType": "points"
}

Stop and target calculated by your strategy

If your Pine strategy calculates its own stop and target prices, the Alert Builder can pass them through instead of fixed distances. It generates this message:

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "price": "{{strategy.order.price}}",
  "bracketSource": "strategy",
  "stopLoss": "{{strategy.order.alert_message}}",
  "stopLossType": "price",
  "takeProfit": "{{strategy.order.alert_message}}",
  "takeProfitType": "price"
}

In Pine, you add the rqBracket() helper the Alert Builder provides and pass it to each entry as alert_message:

if longEntryCondition
    strategy.entry("Long", strategy.long, alert_message = rqBracket(longStopPrice, longTargetPrice))

The helper outputs rqbracket:<stop>:<target>. Connect decodes it and rejects the order if the stop and target are not on the correct sides of the entry price. Add disable_alert = true to the matching strategy.exit() calls, because the bracket already handles the exit at the broker.

Limit order

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "MNQ",
  "side": "buy",
  "quantity": 1,
  "order_type": "limit",
  "price": "{{close}}"
}

order_type only works in snake_case.

Close the position

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "close"
}

Reverse in one alert

{
  "exchange": "tradovate",
  "accountId": 12345678,
  "symbol": "{{ticker}}",
  "side": "sell",
  "quantity": 1,
  "flattenFirst": true
}

If the account is long 1 contract, this sends a single sell for 2: one closes the long, one opens the short.

Several accounts with different sizes

{
  "exchange": "tradovate",
  "symbol": "{{ticker}}",
  "side": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "price": "{{strategy.order.price}}",
  "accounts": [
    { "accountId": 11111111 },
    { "accountId": 22222222, "quantityMultiplier": 2 },
    { "accountId": 33333333, "fixedQuantity": 1 }
  ]
}

When the strategy trades 1 contract, the first account trades 1, the second trades 2 and the third always trades 1. More on this in multi-account futures trading.

TradingView Placeholders Reference

From TradingView's variable documentation:

PlaceholderContainsWorks in
{{ticker}}Chart symbolAll alerts
{{exchange}}Exchange of the symbolAll alerts
{{close}}Bar close priceAll alerts
{{time}}Bar timeAll alerts
{{interval}}Chart timeframeAll alerts
{{strategy.order.action}}Order side (buy or sell)Strategy alerts
{{strategy.order.contracts}}Order sizeStrategy alerts
{{strategy.order.price}}Order fill priceStrategy alerts
{{strategy.order.id}}Order ID from your Pine codeStrategy alerts
{{strategy.order.alert_message}}The order's alert_message argumentStrategy alerts
{{strategy.market_position}}Position after the orderStrategy alerts
{{strategy.position_size}}Position size after the orderStrategy alerts

Common Mistakes

Hardcoding an expired contract. "symbol": "ESH5" stops working when that contract expires. Use the root symbol (ES) or {{ticker}} so the alert trades the current front month. If you use Allowed Symbols with {{ticker}}, list continuous symbols such as ES1! exactly as the alert sends them.

Leaving out the account. Connect needs accountId, accountIds or accounts in every message.

Pasting the URL into the message. The webhook URL goes in the Notifications tab. The message holds only the JSON.

Using strategy placeholders in an indicator alert. {{strategy.order.action}} is empty outside strategy alerts, so the order has no side.

Writing orderType. Only order_type is read. A camelCase orderType is ignored, and the order goes in as market.

Unquoted placeholders. They make the saved message invalid JSON and fail in ways that are hard to spot. Quote them.

Expecting a symbol filter in the JSON. Symbol restrictions live in Connect's Allowed Symbols setting, not in the message. If a symbol isn't on the list, the order is blocked. On continuous-contract charts {{ticker}} sends symbols such as MNQ1!, which does not match MNQ, so list each symbol exactly as your alert sends it, or send a fixed root symbol instead of {{ticker}}.

Related Guides

Skip the Hand-Written JSON

Connect's Alert Builder generates a correct message for your accounts, sizing and exits, ready to paste into TradingView. Every order it places shows up in Executions with the exact payload that triggered it.

Start your 7-day free trial · Read the Connect setup guide

Automated trading involves risk of loss.

Share this article:

Automate Your TradingView Alerts with Roboquant Connect

Route TradingView alerts to your Tradovate accounts. Start with a 7-day free trial.