How To Format TradingView JSON Alert Messages For Futures Bots

Bridge the gap between TradingView and your broker. Learn to format JSON payloads and dynamic placeholders for reliable, automated futures trade execution.

Formatting TradingView alert messages for a futures bot requires a structured JSON payload with fields for symbol, action, quantity, and order details. The webhook receiver parses these fields to execute trades on your broker. Use Pine Script placeholders like {{strategy.order.action}} and {{ticker}} to populate values dynamically, then validate with a JSON linter before going live.

Key Takeaways

  • A working alert message uses valid JSON with required fields: symbol, action (buy/sell), quantity, and order type.
  • TradingView placeholders such as {{ticker}}, {{close}}, and {{strategy.order.action}} pull live values into your payload at trigger time.
  • JSON syntax errors (missing commas, unquoted strings, smart quotes) are the top cause of failed webhook executions.
  • Test every alert template with a JSON validator and a webhook inspection tool before connecting to a live futures account.

Table of Contents

What Is a TradingView Alert Message for a Futures Bot?

A TradingView alert message for a futures bot is the text payload sent to a webhook URL when an alert fires. The bot reads this payload, parses the fields, and submits an order to your futures broker. Most modern automation platforms expect JSON, though some accept plain-text key-value pairs.

The message body sits inside the alert dialog under "Message." When the alert triggers, TradingView posts that exact text to your webhook endpoint. Your bot has no other way to know what to do, so the format matters more than almost any other setting.

Webhook payload: The data sent in an HTTP POST request when a TradingView alert fires. For futures automation, this is typically a JSON object describing the trade.

JSON Structure: The Required Fields

A valid JSON payload for a futures bot needs at minimum a symbol, an action, a quantity, and an order type. Most platforms also accept optional fields for stop loss, take profit, and account routing. The JSON must be syntactically valid, every key in double quotes, every string value in double quotes, and no trailing commas.

Here is a minimal template that works with most futures automation receivers:

{
"symbol": "ESZ2025",
"action": "buy",
"quantity": 1,
"order_type": "market",
"account": "your_account_id"
}

For bracket orders with attached exits, add stop and target fields:

{
"symbol": "NQZ2025",
"action": "buy",
"quantity": 2,
"order_type": "market",
"stop_loss": 21450.00,
"take_profit": 21550.00,
"account": "your_account_id"
}
JSON (JavaScript Object Notation): A lightweight data format using key-value pairs inside curly braces. Webhook receivers parse JSON to extract trade instructions reliably.

Field-by-Field Requirements

  • symbol: The contract identifier your broker expects. ES, NQ, GC, CL on most platforms; some require a month/year suffix like ESZ2025.
  • action: Usually "buy" or "sell." Some receivers also accept "exit" or "close" to flatten positions.
  • quantity: Integer number of contracts. Use 1 for ES or NQ on small accounts; micros (MES, MNQ) let you trade fractional exposure.
  • order_type: "market," "limit," or "stop." Limit and stop orders require a price field.
  • account: Required when your platform routes to multiple broker accounts. Optional for single-account setups.

How Do TradingView Placeholders Work in Alert Messages?

TradingView placeholders are double-curly-brace tokens like {{close}} or {{ticker}} that get replaced with live values when the alert fires. This lets one alert template handle dynamic data without you editing it for every trade. The replacement happens server-side before the webhook is sent.

The most useful placeholders for futures bots:

  • {{ticker}} — the chart symbol (e.g., ESZ2025)
  • {{close}} — the closing price of the bar that triggered the alert
  • {{strategy.order.action}} — "buy" or "sell" from a Pine Script strategy
  • {{strategy.order.contracts}} — number of contracts from the strategy
  • {{strategy.position_size}} — current position size after the order
  • {{time}} — bar timestamp in ISO format
  • {{interval}} — chart timeframe (1, 5, 15, etc.)

A dynamic template using placeholders looks like this:

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

Note that numeric placeholders like {{close}} and {{strategy.order.contracts}} should NOT be wrapped in quotes. String values like {{ticker}} and {{strategy.order.action}} must be quoted. Mixing this up is one of the most common reasons webhooks fail to parse.

Common Alert Message Patterns for Futures

Most futures automation falls into three message patterns: a simple market entry, a bracket order with stops and targets, and a position-flip signal. Knowing the pattern your strategy needs keeps the JSON minimal and easier to debug.

Pattern 1: Simple Market Entry

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

Good for testing or for strategies that manage exits separately on the broker side.

Pattern 2: Bracket Order

{
"symbol": "{{ticker}}",
"action": "{{strategy.order.action}}",
"quantity": 1,
"order_type": "market",
"stop_loss": {{plot_0}},
"take_profit": {{plot_1}}
}

Use Pine Script plot() outputs to pass calculated stop and target prices. This is common for ATR-based stops or structure-based targets.

Pattern 3: Position Flip

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

When TradingView's strategy.entry() reverses a position, contracts will equal twice the position size. Setting reduce_only to false lets the bot flip from short to long in one fill.

Bracket order: An entry order paired with a stop loss and a profit target. Both exits go to the broker as resting orders the moment the entry fills.

Common Formatting Mistakes

Most failed alerts trace back to a small handful of formatting errors. Catching these before you go live saves real money.

  • Smart quotes: Pasting from Word or Notes can swap straight quotes for curly ones. JSON parsers reject these. Always type directly into TradingView or use a plain-text editor.
  • Trailing commas: A comma after the last field breaks JSON. {"a":1,"b":2,} fails; {"a":1,"b":2} works.
  • Quoted numbers: Wrapping {{close}} in quotes turns a number into a string. Some receivers handle this, many don't.
  • Unquoted strings: The opposite problem. "action": buy fails; "action": "buy" works.
  • Wrong placeholder names: {{strategy.order.action}} works inside a strategy alert, but not a study alert. Mismatching alert type and placeholder produces empty values.
  • Missing contract month: Some brokers reject "ES" and require "ESZ2025." Check your broker's symbol format before deployment.

Testing Your Alert Message Format

Validate the JSON in a linter like jsonlint.com before saving the alert. Then point the webhook at a tool like webhook.site or RequestBin to see the exact payload TradingView sends after placeholder substitution. Only after both pass should you connect the alert to a live futures account.

For paper testing, most automation platforms include a simulator that accepts the same JSON your live bot expects. Run at least 20-30 alerts through paper trading before going live. Confirm fills, position size, and stop placement match what your Pine Script intended.

If you're working through webhook setup end-to-end, the TradingView automation guide covers the full pipeline. For payload-specific issues, the JSON payload format reference goes deeper on field requirements across platforms.

Frequently Asked Questions

1. Does TradingView send the alert message exactly as I type it?

Yes, with one exception: any {{placeholder}} tokens are replaced with live values before sending. Everything else, including whitespace and line breaks, is sent verbatim to the webhook URL.

2. Can I send plain text instead of JSON to my futures bot?

Some receivers accept plain text or simple comma-separated formats, but JSON is the standard and is far easier to parse reliably. Check your automation platform's documentation for the exact format it expects.

3. Why is my alert message arriving with empty fields?

Empty fields usually mean you used strategy placeholders ({{strategy.order.action}}) inside a study/indicator alert, where they don't exist. Switch to a strategy alert or use placeholders that work in studies, like {{ticker}} and {{close}}.

4. Do I need TradingView Premium to use webhooks for futures automation?

Webhook alerts require at minimum the Essential plan; Premium raises alert limits and allows more concurrent alerts. Review plan tier requirements to match your trading frequency.

5. How do I include dynamic stop loss and take profit prices?

Calculate the levels in Pine Script with plot() statements and reference them as {{plot_0}}, {{plot_1}}, etc. in the alert message. Make sure these are unquoted in the JSON so they pass as numbers.

Conclusion

A clean TradingView alert message is mostly about disciplined JSON: required fields, correct quoting, and matching placeholders to the alert type. Test in a validator and a webhook inspector before any live capital is at stake.

For deeper coverage of the full automation pipeline, read the complete TradingView automation guide and the webhook setup walkthrough.

Want to dig deeper? Read our complete guide to TradingView automation for detailed setup instructions and broker integration patterns.

References

  1. TradingView. "About Webhooks." tradingview.com/support
  2. TradingView. "Alert Placeholders." tradingview.com/support
  3. CME Group. "E-mini S&P 500 Contract Specifications." cmegroup.com
  4. JSON.org. "Introducing JSON." json.org

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

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.