TradingView Webhook JSON: Alert Message Syntax Explained
Updated · July 2026 · ~10 min read
The most important part of a TradingView webhook alert is not the chart condition. It is the text inside the alert Message box. That message is what tells TradeAon which symbol to trade, whether to buy or sell, how much volume to use, and which secret token proves the request belongs to you.
- TradeAon expects a valid JSON object with
symbol,action,volume,stop_loss,take_profitandsecretfields, plus optionalorder_typeandpricefor pending orders. - The supported actions are BUY, SELL, CLOSE, CLOSE_ALL, CLOSE_BUY, CLOSE_SELL, CANCEL, CANCEL_ALL, CANCEL_BUY and CANCEL_SELL. Combining BUY/SELL with
order_typeplaces Buy/Sell Limit and Buy/Sell Stop orders. - Add
"close_percent"to a close alert to close a portion of the position (for example50for 50%) instead of specifying an exactvolume. - TradingView placeholders such as
{{ticker}}and{{strategy.order.contracts}}can make the same alert message adapt to each strategy order. - Most failed alerts come from invalid JSON: smart quotes, trailing commas, missing quotes around strings or a missing secret.
- What the message box really sends
- The minimum valid JSON payload
- Every field explained
- Action values and when to use them
- Pending orders: limit and stop entries
- Closing part of a position and canceling pending orders
- Static alert messages
- Dynamic messages with placeholders
- Strategy-driven alerts
- Stop loss, take profit and volume notes
- Common formatting mistakes
- Testing safely before live use
01 What the message box really sends
When a TradingView alert fires with Webhook URL enabled, TradingView sends an HTTP POST request to the URL you entered. The webhook URL identifies where the request should go; the message body explains what the request means. For TradeAon, the URL uses your license key, for example https://allinconnect.online/<license_key>, and the license key starts with whk_.
The Message box should contain machine-readable JSON, not a sentence such as "buy EURUSD now". JSON gives the receiving service predictable field names and values. That matters because an Expert Advisor running inside MetaTrader or cTrader eventually needs precise instructions, not a notification written for a human.
02 The minimum valid JSON payload
A clear starting point is a fixed order message. This example opens a 0.10 lot buy on EURUSD with a stop loss and take profit:
{
"symbol": "EURUSD",
"action": "BUY",
"volume": 0.10,
"stop_loss": 1.0850,
"take_profit": 1.0950,
"secret": "your-secret-here"
}
JSON is strict. Field names use double quotes. Text values use double quotes. Numeric values such as 0.10 do not need quotes. The final field does not have a comma after it.
03 Every field explained
symbol: the instrument name from TradingView, such asEURUSD,XAUUSDorBTCUSD. TradeAon can automatically map common broker variants such asGOLD,XAU/USD, suffixes like.m,.proand.raw.action: the operation to perform. It must resolve to one of the supported action values.volume: the requested trade size. Your broker still decides whether that lot size is valid for the symbol and account type.stop_lossandtake_profit: stop-loss and take-profit prices. Use numbers that make sense for the symbol's price scale, or set them to0if your workflow manages exits separately.order_type(optional):market(the default when omitted),limitorstop. Limit and stop turn the request into a pending order.price(required for pending orders): the entry price for alimitorstoporder. A pending-order payload withoutpriceis rejected.ticket(optional): targets one specific position or pending order by its ticket number instead of matching by symbol. Used withCLOSEorCANCEL.position_type(optional):BUYorSELL. Narrows aCLOSE_ALLalert to only that side of the market.close_percent(optional): a number between0and100. Closes that percentage of the position's currently open volume instead of a fixedvolume. See section 06.secret: optional. Blank and not checked unless you set your own value in your account settings; when set, requests missing it (or sending the wrong value) are rejected. It is separate from thewhk_license key already embedded in your webhook URL, which is always required. If you use it, keep it out of screenshots and public scripts.
04 Action values and when to use them
BUY and SELL open long and short positions. CLOSE is used when your strategy wants to close a matching position for the symbol. CLOSE_ALL is broader and should be reserved for deliberate exit logic, such as a daily shutdown condition or emergency flattening rule. CLOSE_BUY and CLOSE_SELL are useful when you allow both directions and want to close only one side.
CANCEL, CANCEL_ALL, CANCEL_BUY and CANCEL_SELL remove pending (not-yet-filled) limit and stop orders instead of open positions — the same side/ticket rules as the CLOSE actions apply. CANCEL with a ticket removes one specific pending order, which is the safe way to replace a single order without touching any others resting on the same symbol.
Do not treat close or cancel actions as risk management by themselves. A close signal can fail if the market is closed, the terminal is offline, the EA is not attached, or the broker rejects the request. Always design automated strategies so the broker-side stop loss is still sensible.
05 Pending orders: limit and stop entries
Everything so far describes a market order — when order_type is omitted, TradeAon fills the request at the current price. To place a pending order instead, keep action as BUY or SELL, add "order_type": "limit" or "order_type": "stop", and supply the entry price. The combination decides the order type your terminal receives:
- BUY + limit → Buy Limit: enter long below the current price (buy a pullback).
- SELL + limit → Sell Limit: enter short above the current price (sell a rally).
- BUY + stop → Buy Stop: enter long above the current price (buy a breakout).
- SELL + stop → Sell Stop: enter short below the current price (sell a breakdown).
This example places a Buy Stop above the market, with the stop loss and take profit set relative to the pending entry price:
{
"symbol": "EURUSD",
"action": "BUY",
"order_type": "stop",
"price": 1.0980,
"volume": 0.10,
"stop_loss": 1.0930,
"take_profit": 1.1060,
"secret": "your-secret-here"
}
Two rules to remember. First, price is required for limit and stop orders — a pending payload without it is rejected before it reaches your terminal. Second, the broker validates the entry level: a Buy Limit above the market or a Buy Stop below it is invalid, and brokers also enforce a minimum distance from the current price. If a pending order is rejected, check the level against live market price first.
06 Closing part of a position and canceling pending orders
A close alert does not have to close the whole position. Add close_percent instead of volume and TradeAon works out the lot size from whatever is actually open on the terminal at the moment the signal arrives — useful when your Pine strategy does not know the broker-side lot size (for example, "close half the position" on a partial take-profit condition):
{
"symbol": "EURUSD",
"action": "CLOSE",
"close_percent": 50,
"secret": "your-secret-here"
}
close_percent must be a number greater than 0 and up to 100; 100 behaves like closing the whole position. If a plain volume is also present in the same payload, volume takes priority and close_percent is ignored. If the computed lot size rounds below your broker's minimum step, the request is skipped rather than closing more or less than intended — check the EA log if a partial close appears to do nothing.
To remove a pending order before it fills, send CANCEL (with a ticket to target one specific order), or CANCEL_ALL / CANCEL_BUY / CANCEL_SELL for broader cleanup:
{
"symbol": "EURUSD",
"action": "CANCEL",
"ticket": 123456789,
"secret": "your-secret-here"
}
Canceling is idempotent: if the order was already filled or removed, TradeAon reports success instead of an error, so a stray duplicate cancel alert is harmless.
07 Static alert messages
A static message is typed directly into the alert and never changes. It is appropriate for simple alerts, such as "when price crosses this level, buy 0.10 EURUSD". Static messages are easy to audit because every alert has one fixed payload. The drawback is maintenance: if you copy the alert to another symbol, change the lot size, or adjust the stop-loss price, you must edit the JSON manually.
Static alerts are a good first test because they remove Pine Script from the equation. If the static payload works, then the webhook URL, secret, EA connection and platform settings are probably correct.
08 Dynamic messages with placeholders
TradingView placeholders are text tokens replaced at alert time. For example, {{ticker}} becomes the current chart symbol, {{strategy.order.action}} becomes the strategy order direction, and {{strategy.order.contracts}} becomes the strategy order size. A dynamic payload might look like this:
{
"symbol": "{{ticker}}",
"action": "{{strategy.order.action}}",
"volume": {{strategy.order.contracts}},
"stop_loss": 0,
"take_profit": 0,
"secret": "your-secret-here"
}
Placeholders do not make invalid JSON valid. After substitution, the final message must still contain quoted strings and valid numbers. Also confirm that the action text produced by your strategy matches TradeAon's accepted action values.
09 Strategy-driven alerts
For Pine Script strategies, the cleanest workflow is usually to trigger the alert from order fills rather than from a separate indicator condition. That keeps the message aligned with the strategy's own order logic. Use TradingView's strategy placeholders for symbol, direction and contracts, then keep sensitive values such as the secret fixed in the alert message.
If your strategy uses custom sizing or custom exit names, test the final alert text in TradingView's alert log. The goal is to confirm the exact payload TradeAon receives, not just the Pine code you expected to run.
10 Stop loss, take profit and volume notes
Webhook JSON describes intent; the broker enforces trading rules. A volume of 0.01 may be valid on one symbol and invalid on another. Stop-loss and take-profit prices can also be rejected if they are too close to market price or on the wrong side of the order.
Before using a strategy live, run it on a demo account with the same broker symbol names, contract sizes and account type. TradeAon is in Beta, so validate routing, platform settings and broker behavior before risking capital.
11 Common formatting mistakes
- Smart quotes: use plain
"characters, not curly quotes from a document editor. - Trailing commas: JSON does not allow a comma after the final field.
- Missing quotes: field names and text values must be quoted.
- Quoted numbers: keep numeric values as numbers unless the platform specifically expects text.
- Missing secret: only causes a rejection if you have set a secret in your account settings — if you never configured one, requests without it are accepted normally.
12 Testing safely before live use
Start with one static alert on a demo account. Confirm that TradingView fired, TradeAon received the payload, the EA was online, and the broker accepted or rejected the order for an understandable reason. Then move to placeholders and strategy-driven messages.
Never assume a green TradingView alert means a filled trade. Execution still depends on JSON validity, account authorization, the EA, terminal connectivity, symbol mapping, market hours and broker rules.