The #1 question on MQL5 forums and r/algotrading: "What JSON format do I use for TradingView alerts to execute on MT5?" Every trade copier has its own format, and getting it wrong means your alerts fire but nothing executes. This guide covers the exact JSON syntax you need.
TradingView Alert JSON for MT5: How It Works
When a TradingView alert fires, it sends an HTTP POST request to your webhook URL. The message body contains whatever text you typed in the "Message" field — TradingView does not enforce JSON formatting. That is your responsibility.
The flow:
- Pine Script condition triggers → alert fires
- TradingView sends HTTP POST to your webhook URL
- Your copier EA receives the POST body
- EA parses the JSON and executes the trade on MT5
TradingView Copier Pro JSON Format
Here is the exact format TradingView Copier Pro expects:
Basic Buy Order
{
"action": "buy",
"symbol": "EURUSD",
"lot": 0.1,
"sl": 50,
"tp": 100
}
Basic Sell Order
{
"action": "sell",
"symbol": "GBPUSD",
"lot": 0.05,
"sl": 40,
"tp": 80
}
Close Position
{
"action": "close",
"symbol": "EURUSD"
}
Partial Close (50%)
{
"action": "close",
"symbol": "EURUSD",
"percent": 50
}
All Available Fields
| Field | Type | Required | Description |
|---|---|---|---|
action | string | ✅ Yes | "buy", "sell", "close", "modify" |
symbol | string | ✅ Yes | Trading pair (auto-remapped) |
lot | number | For open | Lot size (0.01–100) |
sl | number | No | Stop loss in pips or price |
tp | number | No | Take profit in pips or price |
percent | number | No | Partial close percentage (1–99) |
comment | string | No | Trade comment |
magic | number | No | Magic number for trade identification |
Using Pine Script Variables in JSON
TradingView provides placeholder variables that get replaced with actual values when the alert fires. Here is how to use them correctly in your JSON message:
{
"action": "{{strategy.order.action}}",
"symbol": "{{ticker}}",
"lot": 0.1,
"sl": 50,
"tp": 100,
"comment": "{{strategy.order.id}}"
}
Available Pine Script Placeholders
| Placeholder | Output | Example |
|---|---|---|
{{strategy.order.action}} | buy or sell | "buy" |
{{ticker}} | Symbol name | "EURUSD" |
{{strategy.order.price}} | Order price | 1.08542 |
{{strategy.order.contracts}} | Position size | 10000 |
{{strategy.order.id}} | Order label | "Long Entry" |
{{close}} | Current close | 1.08540 |
{{time}} | Bar time | 2026-03-09T… |
Important: Always wrap placeholders in double quotes. {{strategy.order.action}} without quotes produces invalid JSON because if it outputs buy, the parser sees an unquoted string.
Common JSON Mistakes and Fixes
1. Missing Quotes Around Placeholders
Wrong:
{"action": {{strategy.order.action}}, "symbol": "EURUSD"}
Right:
{"action": "{{strategy.order.action}}", "symbol": "EURUSD"}
2. Trailing Comma
Wrong:
{"action": "buy", "symbol": "EURUSD", "lot": 0.1,}
Right:
{"action": "buy", "symbol": "EURUSD", "lot": 0.1}
3. Single Quotes Instead of Double
Wrong:
{'action': 'buy', 'symbol': 'EURUSD'}
Right:
{"action": "buy", "symbol": "EURUSD"}
4. Wrong Symbol Name
TradingView uses EURUSD but your broker might use EURUSDm or EURUSD.pro. TradingView Copier Pro handles symbol remapping automatically — you always send the TradingView symbol, and the EA maps it to your broker's format.
Advanced: Strategy with Multiple TPs
For strategies that take partial profits, send separate alerts for each TP level:
Entry Alert
{
"action": "buy",
"symbol": "EURUSD",
"lot": 0.3,
"sl": 30,
"tp": 0,
"comment": "ICT_entry"
}
TP1 Alert (Close 33%)
{
"action": "close",
"symbol": "EURUSD",
"percent": 33,
"comment": "TP1_hit"
}
TP2 Alert (Close 50% of Remaining)
{
"action": "close",
"symbol": "EURUSD",
"percent": 50,
"comment": "TP2_hit"
}
Testing Your JSON Before Going Live
- Validate syntax — paste your JSON into JSONLint to check for errors
- Fire a test alert — set up a manual TradingView alert with your JSON message
- Check the EA logs — TradingView Copier Pro logs every received webhook in the Experts tab
- Use a demo account first — verify execution before switching to live
Troubleshooting: Webhook Fires But No Trade
If your TradingView alert fires but no trade appears on MT5, check these in order:
- Is the EA running? Check for the smiley face on the chart
- Is AutoTrading enabled? The AutoTrading button in MT5 must be green
- Is the JSON valid? Copy the Experts tab output and validate it
- Is the symbol correct? Check your broker's exact symbol name
- Is the lot size valid? Some brokers have minimum lot requirements
For a full TradingView webhook troubleshooting guide, check our dedicated article.
Alert → Trade in Under 50ms
TradingView Copier Pro parses your JSON alerts and executes on MT5 instantly. Supports all fields, partial closes, and symbol remapping.
Get TradingView Copier Pro →