TradingView Alert Message JSON: 7 Examples That Actually Work
Copy-paste TradingView alert JSON for every common scenario: market orders, pending orders, partial closes, multi-TP, breakeven, dynamic strategy alerts, and position modification.
July 15, 2026 · 8 min read · TradeHookX Team
The anatomy of an alert message
Every automated trade starts with three required fields: a license key that identifies your account, an action that says what to do, and a symbol that says where. Everything else is optional refinement. The examples below build from the simplest possible signal to fully dynamic strategy automation - each one is valid as-is once you swap in your license key.
1. Market order with stop loss and take profit
The bread-and-butter signal. SL and TP default to pip distance from entry; add sl_type or tp_type to use points, a percentage, or a fixed price level instead.
{ "licenseKey": "TB-XXXX", "action": "buy", "symbol": "EURUSD", "size": 0.1, "sl": 20, "tp": 40 }2. Pending order
Buy limit, buy stop, sell limit, and sell stop are all actions. Add a price for the pending level:
{ "licenseKey": "TB-XXXX", "action": "buylimit", "symbol": "XAUUSD", "size": 0.05, "price": 2380.0, "sl": 50, "tp": 120 }3. Risk-based sizing
Instead of fixed lots, risk a percentage of the balance - the size is computed from the stop distance. This keeps risk constant whether the stop is 10 pips or 100:
{ "licenseKey": "TB-XXXX", "action": "sell", "symbol": "GBPUSD", "size_type": "risk", "risk": 1, "sl": 30, "tp": 60 }4. Multiple take profits with auto-breakeven
Scale out at three levels and move the stop to entry once TP1 fills - the signal manages the whole trade lifecycle:
{ "licenseKey": "TB-XXXX", "action": "buy", "symbol": "US100", "size": 0.3,
"sl": 60, "tp1": 40, "tp1_size": 33, "tp2": 80, "tp2_size": 33, "tp3": 120, "tp3_size": 34,
"be_after_tp1": true }5. Partial close
Close half the position and let the rest run:
{ "licenseKey": "TB-XXXX", "action": "closelongpct", "symbol": "EURUSD", "close_percent": 50 }6. Modify an open position
Set a new stop and target on whatever is open - useful for trailing a position from a higher-timeframe signal:
{ "licenseKey": "TB-XXXX", "action": "newsltplong", "symbol": "EURUSD", "sl": 15, "tp": 55 }7. Fully dynamic strategy alert
One alert for the whole strategy: TradingView placeholders inject the direction, symbol, and size at fire time. This is the recommended pattern for Pine strategies - entries and exits both flow through a single alert:
{ "licenseKey": "TB-XXXX", "action": "{{strategy.order.action}}", "symbol": "{{ticker}}",
"size": "{{strategy.order.contracts}}", "size_type": "units" }When JSON goes wrong
A single missing quote or comma makes TradingView send the message as plain text, which most bridges reject. If a signal never arrives, validate the JSON first. Better: generate the message from a visual Alert Builder and never hand-edit it - every example on this page maps to a form control there.
Keep reading
Ready to automate your strategy?
7-day free trial on every plan. No credit card required.
Start free trial