Trade Command — The Webhook JSON Schema
A trade command is the JSON payload TradingView Hub receives, validates, and forwards to the exchange. It carries every parameter the exchange adapter needs: which market, which direction, how big, with what risk attached, and how to follow up.
- A trade command is a JSON object with 91 possible fields. Most trades use 5–15 of them.
- Normal webhook/manual commands use direction booleans:
isBuy: true,isSell: true, orisClose: true.orderTypeis for TradingView strategy-alert templates. - The Trade Command Builder UI generates the JSON for you, so you rarely hand-write a full payload.
When you'll see a trade command
You encounter the JSON shape in three contexts. Same schema in all three.
| Context | Where the JSON comes from |
|---|---|
| TradingView webhook alert | The alert message body. Pine alert(message=...) emits this string. |
| Trade Command Builder output | The "Copy JSON" button on every exchange page exports the same shape. |
| Saved templates / imports | Save & Load lets you store named templates as JSON and replay them. |
Minimal vs realistic payload
A working market buy is a handful of fields. A typical real-world entry with risk attached is closer to fifteen.
Minimal — market buy 0.01 BTC on Binance Spot:
{
"exchange": "binance",
"pair": "BTCUSDT",
"apiKey": "binance-main",
"isBuy": true,
"units": 0.01,
"unitsType": "absolute",
"token": "YOUR_TOKEN"
}
Realistic — Binance Futures long with leverage, SL, two TPs, idempotency:
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isBuy": true,
"isMarket": true,
"unitsType": "percent",
"unitsPercent": 5,
"leverage": 10,
"marginType": "isolated",
"stopLossType": "percent",
"stopLossPercent": 1.5,
"targetType": "percent",
"targetAmountInPercent": true,
"targets": [
{
"takeProfitPercent": 1.0,
"amount": 50
},
{
"takeProfitPercent": 2.0,
"amount": 50
}
],
"alertTimestamp": "{{ticker}}-{{timenow}}",
"token": "YOUR_TOKEN"
}
The realistic payload adds: which API key, leverage (10x) and margin mode (isolated), 5%-of-available-balance sizing (unitsPercent: 5 at unitsType: "percent"), a 1.5% percent SL, two TPs at +1% and +2% with the position split 50/50, and an idempotency key. None of those are required — they're optional layers you opt into.
How to read this section
Read in this order if you've never built a payload before:
- Anatomy & Auto-Mapping — how TVH reads your JSON, including how it auto-detects strategy alerts. Worth reading first.
- Parameter Reference — sortable master table of all 84 fields. Use as a lookup.
- Category detail pages — Core, Sizing, Stop Loss, Take Profit, Futures, DCA & Scaled, Limit Mgmt, Conditional, Close & Cancel, Timing, Math Expressions.
- Examples — 12 complete Pine + JSON pairs for common setups.
- Gotchas — 15 footguns the parameter table can't warn you about.
For LLMs
If you're feeding the schema to a language model (Claude, GPT, Gemini, Perplexity), use the plain-text bundle:
- Plain text (LLM-friendly):
/llms-full.txtlists all 84 fields as readable text, no MDX wrappers. - JSON Schema (Draft 2020-12):
/schemas/trade-command.schema.jsondrops straight into structured-output tools.
Both stay in sync with the field reference on this page. See For LLMs for a guided primer.
How does a trade command work? A deeper dive
Start with Trade Command Anatomy & Auto-Mapping. It covers the four things the server does on top of your JSON — knowing those saves an afternoon of debugging.