TradingView JSON Payload Format For Automation: Complete Technical Guide

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.

Key Takeaways

  • JSON payloads translate TradingView alerts into executable trade instructions with specific fields for ticker, action, quantity, and order parameters
  • Proper JSON syntax is critical—missing commas, brackets, or quotes will cause webhook failures and prevent trade execution
  • Most automation platforms require standardized JSON fields, though exact formatting varies by platform and broker API
  • Testing JSON payloads in paper trading environments prevents costly syntax errors before deploying to live accounts

Table of Contents

What Is a JSON Payload in TradingView Automation?

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.

Core Structure of TradingView JSON Payloads

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.

Required Fields for Futures Automation

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.

JSON Payload Examples by Order Type

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.

Market Order Example


{
"ticker": "{{ticker}}",
"action": "{{strategy.order.action}}",
"quantity": {{strategy.order.contracts}},
"order_type": "market"
}

Limit Order Example


{
"ticker": "{{ticker}}",
"action": "buy",
"quantity": 2,
"order_type": "limit",
"price": {{close}}
}

Bracket Order Example


{
"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.

Common JSON Formatting Errors and Fixes

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.

JSON Validation Checklist

  • ☐ All keys and string values use double quotes, not single quotes
  • ☐ Commas separate each key-value pair except the last one
  • ☐ Opening and closing braces match ({...})
  • ☐ Numeric values have no quotes (quantity: 1, not "1")
  • ☐ No comments in the JSON (// or /* */ breaks syntax)
  • ☐ TradingView placeholders use correct double-brace syntax {{}}

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.

How to Test Your JSON Payload Before Going Live

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.

Frequently Asked Questions

1. Can I use the same JSON payload for all futures contracts?

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.

2. What happens if my JSON payload has a syntax error?

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.

3. Do I need programming knowledge to create JSON payloads?

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.

4. Can I send multiple orders in one JSON payload?

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.

5. How do I include stop loss and take profit in my JSON payload?

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.

Conclusion

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 →

References

  1. TradingView. "Webhook Alerts Documentation." https://www.tradingview.com/support/solutions/43000529348-i-want-to-know-more-about-webhooks/
  2. CME Group. "E-mini S&P 500 Futures Contract Specs." https://www.cmegroup.com/markets/equities/sp/e-mini-sandp500.html
  3. JSON.org. "Introducing JSON." https://www.json.org/json-en.html
  4. TradingView. "Pine Script Variables and Placeholders." https://www.tradingview.com/pine-script-docs/en/v5/concepts/Alerts.html

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

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

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

  1. Item 1
  2. Item 2
  3. Item 3

Unordered list

  • Item A
  • Item B
  • Item C

Text link

Bold text

Emphasis

Superscript

Subscript

Steal the Playbooks
Other Traders
Don’t Share

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.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.