TradingView Alert Message Variables: Complete Automation Guide

Turn your TradingView charts into automated trade engines using alert variables. Use placeholders like {{ticker}} and {{close}} to execute orders via webhooks.

TradingView alert message variables are dynamic placeholders in your alert notifications that automatically populate with real-time trade data like price, ticker symbol, time, and indicator values. These variables let you send structured information from TradingView to automation platforms or brokers, enabling automated trade execution based on your strategy's specific parameters without manual input.

Key Takeaways

  • Alert message variables use double curly braces syntax like {{ticker}}, {{close}}, and {{time}} to insert live market data
  • JSON-formatted alert messages with variables enable webhook automation by sending structured trade instructions to your broker
  • Common variables include {{ticker}} (instrument), {{close}} (current price), {{volume}} (bar volume), and {{interval}} (timeframe)
  • Custom variables from Pine Script indicators can be accessed using {{strategy.order.action}} and {{strategy.position_size}}

Table of Contents

What Are TradingView Alert Message Variables?

Alert message variables are placeholders that TradingView replaces with actual market data when your alert triggers. Instead of manually typing price levels or ticker symbols, variables automatically insert current values from your chart into the alert message. This makes alerts dynamic and enables automation platforms to parse structured trade instructions.

Variables use a {{double_curly_brace}} syntax that TradingView recognizes and replaces at execution time. For example, {{ticker}} becomes "ES1!" or "NQ1!" depending on which chart fired the alert. {{close}} becomes the actual closing price of the triggering bar, like "4285.50" for ES futures.

Alert Message Variable: A placeholder token in TradingView alerts that gets replaced with real-time market data when the alert fires. Variables enable automated systems to receive structured, actionable trade information without manual intervention.

The primary use case for alert message variables is TradingView automation via webhooks. When you send an alert to an automation platform, variables let you communicate precise trade parameters—entry price, stop loss, take profit, contract symbol—that the platform uses to execute orders with your futures broker.

Most Common Alert Message Variables

TradingView provides built-in variables that cover most trading automation needs. These variables pull data directly from your chart and the alert condition that triggered.

VariableReturnsExample Output{{ticker}}Chart symbolES1!, NQ1!, GC1!{{close}}Bar closing price4285.50{{open}}Bar opening price4282.25{{high}}Bar high price4287.75{{low}}Bar low price4280.00{{volume}}Bar volume45230{{time}}Bar timestamp (Unix)1704124800000{{interval}}Chart timeframe5, 15, 60, D{{timenow}}Current time (Unix)1704124856000

The {{ticker}} variable is essential for multi-chart automation. If you run the same strategy across ES, NQ, and GC, one alert template with {{ticker}} works for all three charts. The automation platform receives "ES1!" from your ES chart and "NQ1!" from your NQ chart without separate alert configurations.

Price variables ({{close}}, {{open}}, {{high}}, {{low}}) let you reference exact levels for order placement. A breakout strategy might use {{high}} as the entry trigger price or {{low}} minus a buffer for a stop loss calculation.

Unix Timestamp: A time format representing seconds (or milliseconds) since January 1, 1970 UTC. TradingView's {{time}} and {{timenow}} variables use milliseconds, which automation platforms convert to human-readable dates.

How to Format Alert Messages with Variables

Most automation platforms require JSON-formatted alert messages because JSON provides structured, parseable data. A properly formatted alert message includes variables wrapped in JSON key-value pairs that your automation platform reads and converts into broker API calls.

Basic JSON structure for a long entry alert:


{
"action": "buy",
"ticker": "{{ticker}}",
"price": {{close}},
"quantity": 1,
"timestamp": {{timenow}}
}

Note that string values like "buy" and {{ticker}} need quotation marks, while numeric variables like {{close}} don't. TradingView inserts the number directly, so quotes would break the JSON format. When the alert fires on an ES chart at 4285.50, the platform receives {"action":"buy","ticker":"ES1!","price":4285.50,"quantity":1,"timestamp":1704124856000}.

Advanced alerts include risk management parameters using variable-based calculations. While TradingView doesn't support math operations inside alert messages directly, you can reference Pine Script variables that contain calculated values:


{
"action": "{{strategy.order.action}}",
"ticker": "{{ticker}}",
"entry": {{close}},
"stop": {{plot_0}},
"target": {{plot_1}},
"size": {{strategy.position_size}}
}

The {{plot_0}} and {{plot_1}} variables reference plotted values from your indicator or strategy. If your Pine Script plots a stop loss level and take profit level, these variables send those exact values to your automation platform.

Pine Script Strategy Variables

Pine Script strategies and indicators can expose custom variables through the alert message. These variables access strategy-specific data like order action, position size, and custom calculations from your script logic.

Key Strategy Variables

  • {{strategy.order.action}} - Returns "buy" or "sell" based on strategy signal
  • {{strategy.order.contracts}} - Number of contracts the strategy wants to trade
  • {{strategy.position_size}} - Current position size (positive for long, negative for short)
  • {{strategy.order.price}} - Strategy's intended order price
  • {{strategy.market_position}} - Returns "long", "short", or "flat"

Strategy variables are particularly useful for automated futures trading because they let TradingView's backtested strategy communicate its exact intentions to your execution platform. A strategy that dynamically adjusts position size based on volatility can send that calculated size via {{strategy.order.contracts}}.

To access custom indicator values, use plot references. If your Pine Script includes plot(stopLoss, "SL", color=color.red), you can reference that value as {{plot("SL")}} or {{plot_0}} (first plot). This approach works for dynamic stop losses, trailing stops, or any calculated level your indicator produces.

Plot Reference Variable: A variable that accesses values plotted on your TradingView chart from Pine Script code. Syntax is {{plot_0}}, {{plot_1}}, etc., or {{plot("name")}} using the plot's label.

One limitation: Pine Script variables only work when alerts are created from strategies or indicators with the specific code. Generic alerts on price levels don't have access to strategy.order.action or custom plots. You need a Pine Script-based alert condition to use these advanced variables.

Using Variables for Webhook Automation

Webhook automation connects TradingView alerts to execution platforms using alert message variables as the data payload. When your alert fires, TradingView sends an HTTP POST request to your webhook URL containing the variable-populated JSON message.

The automation platform receives the JSON, parses the variables (now filled with actual data), validates the structure, and translates it into broker API calls. For ES futures automation, this happens in 3-40ms depending on your broker's API latency.

Essential webhook alert message structure:


{
"ticker": "{{ticker}}",
"action": "buy",
"orderType": "market",
"quantity": 1,
"timeframe": "{{interval}}",
"price": {{close}}
}

The ticker variable ensures the automation platform sends the order to the correct futures contract. The action field tells the platform whether to enter long or short. OrderType specifies market, limit, or stop orders. Price provides reference data even for market orders, useful for logging and verification.

Multi-step strategies use alert message variables to communicate complex order sequences. A bracket order (entry + stop + target) sends three price levels in one alert:


{
"action": "bracket_long",
"ticker": "{{ticker}}",
"entry": {{close}},
"stop": {{plot_0}},
"target": {{plot_1}},
"contracts": 2
}

Platforms like ClearEdge Trading parse this structure and submit a market order for entry, a stop-loss order at {{plot_0}}, and a take-profit limit order at {{plot_1}}—all from a single alert.

Webhook URL: A unique web address provided by your automation platform that receives HTTP POST requests from TradingView. The URL endpoint processes incoming alert data and triggers trade execution logic.

Webhook security considerations: Your webhook URL acts as an API key. Anyone with the URL can send trade commands to your platform. Use platforms that offer IP whitelisting (TradingView's IPs only) or include a secret token in your alert message JSON for validation.

Common Variable Issues and Solutions

Alert message variables fail silently in TradingView—if syntax is wrong, the alert sends the literal text "{{close}}" instead of "4285.50". Your automation platform receives malformed data and rejects the order or throws an error.

Variable Troubleshooting Checklist

  • ☐ Verify double curly braces with no spaces: {{close}} not {{ close }}
  • ☐ Check variable spelling matches TradingView's exact names
  • ☐ Confirm numeric variables have no quotation marks in JSON
  • ☐ Test string variables like {{ticker}} include quotation marks
  • ☐ Validate JSON syntax with a JSON linter before creating alert
  • ☐ Check Pine Script plots exist if using {{plot_0}} references
  • ☐ Ensure strategy variables only used with strategy-based alerts

Common mistake: Using {{symbol}} instead of {{ticker}}. TradingView's variable is {{ticker}}, not {{symbol}}. This error is frequent because many platforms use "symbol" terminology. Always reference TradingView's official variable documentation for exact syntax.

Another issue: Missing commas in JSON or trailing commas after the last key-value pair. JSON is strict about formatting. Use a JSON validator to check your alert message structure before saving the alert in TradingView.

Pine Script variable problems occur when your alert condition doesn't come from the strategy generating the variables. If you create a generic price alert on a chart running a strategy, you can't access {{strategy.order.action}}. The alert must be created from the strategy's "Create Alert" option in the strategy tester panel.

Frequently Asked Questions

1. Can I use alert message variables with any TradingView account?

Alert message variables work on all TradingView paid plans (Pro, Pro+, Premium). Free TradingView accounts don't have webhook functionality, which is required to send variable-populated alerts to automation platforms. Variables themselves function in alerts, but webhook delivery requires a paid subscription.

2. How do I reference multiple indicator values in one alert?

Use plot reference variables like {{plot_0}}, {{plot_1}}, {{plot_2}} corresponding to the order plots appear in your Pine Script code. Alternatively, use {{plot("name")}} syntax with the exact plot label from your code. Include multiple plot variables in your JSON alert message to send several values simultaneously.

3. What happens if a variable returns no value?

If a variable has no value (like {{strategy.position_size}} when no position is open), TradingView typically sends "NaN" (not a number) or an empty string. Most automation platforms reject malformed data, preventing erroneous orders. Test your alerts thoroughly using paper trading before live execution.

4. Can I perform calculations with variables in alert messages?

TradingView alert messages don't support mathematical operations on variables directly. Calculations must happen in your Pine Script code, then expose the result as a plot or strategy variable. For example, calculate your stop loss in Pine Script, plot it, then reference {{plot_0}} in your alert message.

5. Do alert variables work for crypto, stocks, and forex or just futures?

Alert message variables work across all TradingView asset classes—futures, stocks, forex, crypto. The {{ticker}} variable adapts to whatever chart symbol fires the alert. However, automation platform support varies by asset class; many futures automation platforms only support futures contracts specifically.

Conclusion

TradingView alert message variables transform static alerts into dynamic, structured data streams that enable automated trade execution. Using variables like {{ticker}}, {{close}}, and strategy-specific parameters, you can build sophisticated automation systems without manually entering trade details for every signal.

Master JSON formatting with proper variable syntax, test alerts using your broker's paper trading environment, and validate message structure before going live. For comprehensive webhook setup guidance, see our complete TradingView automation guide.

Want to see variables in action? Read our complete TradingView automation guide for webhook setup, Pine Script examples, and broker integration instructions.

References

  1. TradingView - How to Use Variable Values in Alerts
  2. TradingView - Pine Script Alert Documentation
  3. CME Group - E-mini S&P 500 Futures Contract Specifications
  4. JSON.org - JSON Syntax Standards

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.