WEBHOOK PAYLOAD REFERENCE

TradingView webhook alert JSON templates

Copy-ready JSON message templates for TradingView strategy and indicator webhooks — covering both TradeAdapter API v4 Saved Strategies and the MetaTrader 4/5 Expert Advisor.

In TradeAdapter API v4, broker credentials, market type, leverage, SL/TP and trailing stops are stored securely on your saved Strategy — never put broker API keys or secrets inside a TradingView alert.

SETUP WORKFLOW

How to connect in three steps

Direct API v4: alert-sized strategy

Point TradingView at your webhook URL and send only strategy_name, {{strategy.order.action}} and {{strategy.order.contracts}}. Market, broker and risk live on the server Strategy.

Direct API v4: fixed-size or indicator alerts

When Strategy quantity mode is fixed or driven by an indicator, use an explicit order_action ("buy" / "sell") and include "order_price": "{{close}}" when protective rules use a reference price.

MetaTrader 4/5 Expert Advisor alerts

Include mt_trading_account, "platform": "metatrader", TradingView placeholders and target_type ("none", "percentage" or "pips") with lot-denominated order_contracts.

KEY CAPABILITIES

Execution features and controls

Zero API keys in alert messages

Direct API v4 strategies reference strategy_name only, keeping exchange keys encrypted inside My Brokers.

Dynamic Pine placeholders

Uses standard TradingView variables: {{strategy.order.action}}, {{strategy.order.contracts}}, {{close}}, {{ticker}} and {{timenow}}.

Consistent Strategy vs Indicator contract

One template works for strategy.* alerts, while paired Buy and Sell alerts drive non-strategy indicator conditions.

Validated against TradeAdapter v4 & MT EA

Every field below matches the live TradeAdapter v4 Strategy parser and MetaTrader Expert Advisor setup docs.

ALERT PAYLOADS

Copy-ready TradingView alert JSON

API v4 Direct Broker — Pine Strategy (alert quantity mode)

Reads {{strategy.order.action}} and {{strategy.order.contracts}} from TradingView. Server-side SL/TP and ladder targets apply automatically from your saved Strategy.

{
  "strategy_name": "my-saved-strategy",
  "order_action": "{{strategy.order.action}}",
  "order_contracts": "{{strategy.order.contracts}}"
}

API v4 Direct Broker — Strategy (fixed server quantity + reference price)

Omits order_contracts when your saved Strategy defines a fixed order size on the server.

{
  "strategy_name": "my-saved-strategy",
  "order_action": "{{strategy.order.action}}",
  "order_price": "{{close}}"
}

API v4 Direct Broker — Indicator Buy alert (duplicate with "sell" for Sell alert)

Create two TradingView alerts on your indicator condition: one with "order_action": "buy" and one with "order_action": "sell".

{
  "strategy_name": "my-saved-strategy",
  "order_action": "buy",
  "order_price": "{{close}}"
}

MetaTrader 4 & 5 EA — Pine Strategy with percentage SL/TP

Paste into TradingView Alert Message for the MetaTrader Expert Advisor; keep order_contracts in lots.

{
  "mt_trading_account": "YOUR_MT_ACCOUNT_NUMBER",
  "platform": "metatrader",
  "time": "{{timenow}}",
  "ticker": "{{ticker}}",
  "order_type": "Market",
  "order_contracts": "{{strategy.order.contracts}}",
  "order_action": "{{strategy.order.action}}",
  "order_price": "{{strategy.order.price}}",
  "target_type": "percentage",
  "stop_loss": "0.01",
  "take_profit": "0.02",
  "market_position": "{{strategy.market_position}}",
  "market_position_size": "{{strategy.market_position_size}}",
  "prev_market_position": "{{strategy.prev_market_position}}",
  "prev_market_position_size": "{{strategy.prev_market_position_size}}",
  "strategy_number": "1"
}
FAQ

Frequently asked questions

API v4 routes alerts through strategy_name and stores encrypted broker credentials on the TradeAdapter server, preventing secret leaks and rejected legacy payloads.

No. In API v4 indicator mode, create two separate TradingView alerts referencing the same strategy_name: one sending "order_action": "buy" and the other "order_action": "sell".

For MetaTrader 4 and 5 accounts, yes — the Expert Advisor runs inside your terminal, so MT4/MT5 must stay online with Algo Trading enabled (often on a VPS). Direct API brokers run server-to-server without MetaTrader.