Translate your TradingView alerts into instant trade execution. Master JSON payload structures, required fields, and syntax to automate your futures strategy.

TradingView JSON payload format for automation refers to the structured data format used to send trade instructions from TradingView alerts to automation platforms via webhooks. The JSON payload contains key-value pairs specifying order details like ticker symbol, action (buy/sell), quantity, order type, and price parameters, enabling your TradingView alerts to execute trades automatically through your broker without manual intervention.
A JSON payload is the structured message your TradingView alert sends to your automation platform when an alert condition triggers. JSON (JavaScript Object Notation) is a lightweight data format that organizes information into key-value pairs, making it readable by both humans and machines. When your Pine Script indicator fires an alert, the JSON payload carries the trade instructions—ticker symbol, buy or sell action, quantity, order type—through the webhook URL to your broker's API for execution.
Webhook: A webhook is an automated HTTP callback that sends data from one application to another when a specific event occurs. In TradingView automation, webhooks transmit your JSON payload from TradingView to your automation platform the moment your alert triggers.
The automation platform reads the JSON payload, validates the syntax, extracts the trade parameters, and submits the order to your futures broker. Without correctly formatted JSON, the automation chain breaks—your alert fires, but no trade executes. According to TradingView's official webhook documentation, proper JSON structure is mandatory for reliable alert-to-execution workflows.
Most no-code platforms like ClearEdge Trading provide JSON templates, reducing the need for manual coding. You fill in variables like {{ticker}} and {{strategy.order.action}} using TradingView's built-in placeholder syntax, and the platform handles the rest.
JSON payloads follow a strict syntax using curly braces, colons, and commas. A basic payload structure looks like this: the opening curly brace starts the object, each key-value pair is separated by a colon, pairs are separated by commas, and the closing curly brace ends the object. Keys must be enclosed in double quotes, and string values also require double quotes.
Here's a minimal example for a market order on ES futures:
{
"ticker": "ESZ2024",
"action": "buy",
"quantity": 1,
"order_type": "market"
}
JSON Syntax: JSON requires strict formatting—double quotes for strings, no trailing commas, and proper nesting of objects and arrays. A single misplaced comma or missing quote will invalidate the entire payload.
TradingView supports dynamic values using placeholder variables. Instead of hardcoding "buy" or "sell," you use {{strategy.order.action}} so the payload adapts to your strategy's signals. This allows one alert configuration to handle both long and short entries. The TradingView automation guide covers placeholder syntax in detail.
Nested objects and arrays extend JSON capabilities. For bracket orders (entry with stop loss and take profit), you nest additional objects within the main payload to specify multiple order legs simultaneously.
Futures automation requires specific fields to execute trades correctly. The ticker field identifies the contract (ES, NQ, GC, CL), the action field specifies buy or sell, quantity indicates contract count, and order_type defines execution method (market, limit, stop). Missing any required field typically results in order rejection.
FieldPurposeExample ValuestickerContract symbol"ESH2025", "NQM2025", "GCJ2025"actionTrade direction"buy", "sell", "close"quantityNumber of contracts1, 2, 5order_typeExecution method"market", "limit", "stop"priceLimit/stop price (conditional)5000.00, 4985.50
For limit and stop orders, the price field becomes mandatory. Market orders ignore the price field since they execute at the best available price. Some platforms require additional fields like account_id for multi-account setups or time_in_force for order duration (GTC, DAY, IOC).
Futures contract symbols must match your broker's format exactly. ES futures might be "ESH2025" (month code + year) at one broker and "ES MAR25" at another. Check supported brokers documentation for symbol formatting requirements.
Contract Expiration Codes: Futures use letter codes for months—H (March), M (June), U (September), Z (December) for quarterly contracts. The year follows the letter, so "ESH2025" is the March 2025 E-mini S&P 500 contract.
Position management fields like position_side (long/short) and reduce_only (true/false) help manage existing positions. Setting reduce_only to true prevents accidentally opening new positions when you intend to close or reduce existing ones.
Different order types require different JSON structures. Market orders need minimal fields, limit orders add price specification, and bracket orders combine entry with protective stops and profit targets in a single payload.
{
"ticker": "{{ticker}}",
"action": "{{strategy.order.action}}",
"quantity": {{strategy.order.contracts}},
"order_type": "market"
}
{
"ticker": "{{ticker}}",
"action": "buy",
"quantity": 2,
"order_type": "limit",
"price": {{close}}
}
{
"ticker": "NQH2025",
"action": "buy",
"quantity": 1,
"order_type": "market",
"stop_loss": {
"price": {{strategy.order.price}} - 50,
"order_type": "stop"
},
"take_profit": {
"price": {{strategy.order.price}} + 100,
"order_type": "limit"
}
}
Bracket orders protect your position immediately upon entry. The stop_loss and take_profit objects nest within the main order, creating three orders simultaneously—the entry plus two exit orders. NQ futures move in 0.25 point increments worth $5.00 per contract, so a 50-point stop loss represents $250 risk per contract.
Advanced payloads can include conditional logic using TradingView's alert message box. Some traders send different JSON structures based on indicator values, switching between aggressive and conservative position sizing depending on market volatility.
JSON syntax errors are the leading cause of webhook failures. Missing commas between key-value pairs, using single quotes instead of double quotes, including trailing commas after the last pair, and mismatched brackets all break JSON parsing.
A common mistake is wrapping TradingView variables in quotes when they represent numbers. Writing "quantity": "{{strategy.order.contracts}}" treats the value as text. Correct format is "quantity": {{strategy.order.contracts}} without quotes, so the number passes through properly.
JSON Validator: A JSON validator is an online tool that checks your payload syntax before deployment. Tools like JSONLint.com identify errors and show exactly where formatting breaks occur.
Copy-pasting JSON from documents sometimes introduces invisible Unicode characters that look like normal quotes but break parsing. Always type JSON directly in TradingView's alert message box or use a plain text editor, not Word or Google Docs.
Testing with static values first helps isolate issues. Replace all {{placeholders}} with actual values like "ESH2025" and 1 to verify basic structure. Once that works, reintroduce TradingView variables one at a time.
Testing JSON payloads in paper trading environments prevents real money losses from syntax errors or logic mistakes. Set up a webhook pointing to your automation platform's paper trading endpoint, fire test alerts manually, and verify orders appear correctly in your paper trading account.
TradingView's Strategy Tester provides historical alert data. Run your strategy on historical bars and check how many alerts would have fired. If your strategy generated 50 alerts but your paper account shows only 30 orders, you have a webhook or JSON issue to debug.
Log files from your automation platform reveal exactly what JSON it received. Most platforms including ClearEdge Trading provide webhook logs showing raw payload data, parsing results, and error messages. A 400 error typically indicates malformed JSON, while 401 suggests authentication problems.
Error CodeMeaningCommon Cause400Bad RequestInvalid JSON syntax401UnauthorizedWrong API key or webhook URL422UnprocessableMissing required field500Server ErrorPlatform or broker API issue
Start with single contract orders and simple market execution. Once those work reliably, add complexity like limit orders, brackets, and larger position sizes. The futures instrument automation guide covers instrument-specific testing considerations for ES, NQ, GC, and CL contracts.
Run alerts during off-peak hours first. Testing during high-volatility events like NFP releases introduces execution variability that makes it harder to isolate JSON issues. Validate your setup during calm market periods before deploying during economic announcements.
Yes, if you use TradingView's {{ticker}} placeholder variable instead of hardcoding the contract symbol. The ticker variable automatically adjusts to whatever chart you're viewing when the alert fires. Just ensure your automation platform supports dynamic ticker resolution.
The webhook request fails and no trade executes. Most automation platforms log the error and send you a notification, but your TradingView alert still fires—the breakdown happens at the payload parsing stage. Always test JSON syntax with a validator before going live.
Basic JSON structure is straightforward—curly braces, key-value pairs, and commas. No-code platforms provide templates where you fill in blanks rather than writing from scratch. Understanding syntax rules helps troubleshoot issues, but you don't need developer-level programming skills.
It depends on your automation platform. Some support array syntax where you list multiple order objects in brackets, while others require separate alerts for each order. Bracket orders (entry + stop + target) typically bundle in one payload using nested objects.
Use nested objects with stop_loss and take_profit keys containing their own price and order_type fields. Format depends on your platform—some use OCO (one-cancels-other) brackets, others use parent-child order relationships. Check your platform's documentation for exact syntax.
Proper JSON payload formatting is the technical foundation of TradingView automation. Understanding required fields, avoiding common syntax errors, and testing thoroughly in paper trading ensures your alerts translate into actual trades without manual intervention.
Start with simple market orders using validated JSON templates, verify execution in paper trading, then gradually add complexity like limit orders and brackets as you gain confidence in your automation setup.
Start automating your trades. View ClearEdge Pricing →
Disclaimer: This article is for educational purposes only. It is not trading advice. ClearEdge Trading executes trades based on your rules—it does not provide signals or recommendations.
Risk Warning: Futures trading involves substantial risk. You could lose more than your initial investment. Past performance does not guarantee future results. Only trade with capital you can afford to lose.
CFTC RULE 4.41: Hypothetical results have limitations and do not represent actual trading.
By: ClearEdge Trading Team | About
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Block quote
Ordered list
Unordered list
Bold text
Emphasis
Superscript
Subscript
Every week, we break down real strategies from traders with 100+ years of combined experience, so you can skip the line and trade without emotion.
