TradeAon · Guides · TradingView → MetaTrader
Webhooks

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.

Key takeaways
Contents
  1. What the message box really sends
  2. The minimum valid JSON payload
  3. Every field explained
  4. Action values and when to use them
  5. Pending orders: limit and stop entries
  6. Closing part of a position and canceling pending orders
  7. Static alert messages
  8. Dynamic messages with placeholders
  9. Strategy-driven alerts
  10. Stop loss, take profit and volume notes
  11. Common formatting mistakes
  12. 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

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:

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

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.

TradeAon is a technical automation tool, not financial advice. Trading involves substantial risk of loss. You are responsible for your own strategy, risk and capital.