TradingView Alert Message Variables Explained
TradingView alert placeholders are tokens in double curly braces that get replaced with live values when an alert fires. Market placeholders like {{ticker}} and {{close}} work in any alert. Strategy placeholders like {{strategy.order.action}} only resolve inside strategy alerts and will appear literally anywhere else. The most common mistake is assuming {{close}} is the current price — it is the closing price of the bar that triggered the alert, which on an intrabar trigger is not the same thing.
Market and symbol placeholders
{{ticker}} — the symbol, without exchange prefix.
{{exchange}} — the exchange the symbol trades on.
{{interval}} — the chart timeframe. Useful when one endpoint serves alerts from several timeframes.
{{close}}, {{open}}, {{high}}, {{low}}, {{volume}} — OHLCV of the bar that triggered the alert.
{{time}} — the bar's opening time, UTC.
{{timenow}} — the moment the alert fired, UTC.
The distinction between the last two matters more than it looks. On a bar-close trigger they are close together. On an intrabar trigger they can be a full bar apart, and using the wrong one produces timestamps that make debugging much harder later.
Strategy placeholders
These resolve only in alerts created from a strategy. In an indicator or price alert they appear as literal text.
{{strategy.order.action}} — buy or sell.
{{strategy.order.contracts}} — the order's quantity.
{{strategy.order.price}} — the price the order was filled at in the simulation.
{{strategy.order.id}} — the order identifier from the script.
{{strategy.order.comment}} — the comment attached to the order in Pine Script, if set.
{{strategy.order.alert_message}} — the per-order message defined in the script. This is the most powerful one; see below.
{{strategy.position_size}} — position size after this order. Positive is long, negative short, zero flat.
{{strategy.market_position}} and {{strategy.prev_market_position}} — position state as text, current and previous.
The position placeholders are what let a receiver reason about intent rather than guessing. A sell that takes position size from positive to zero is a close; a sell that takes it from zero to negative is a short entry. Same action, different order, and only the position context distinguishes them.
Indicator plot values
{{plot_0}}, {{plot_1}} and so on reference an indicator's plotted series by index, and {{plot("name")}} references one by name.
Index-based references are fragile: adding or reordering plots in the script silently shifts what each index points to, and the alert keeps firing with the wrong value. Prefer names.
The alert_message placeholder
This is the one worth understanding properly, because it changes what a single alert can do.
Pine Script order functions accept an alert_message argument, and whatever string that argument holds is substituted into {{strategy.order.alert_message}} when the alert fires. The string can be built in the script from variables.
The consequence is that the payload becomes dynamic. Rather than one static template for every order, each order carries its own message computed at signal time — different sizes, different order types, different exit instructions, all from one alert configuration.
The practical pattern is to construct the entire JSON payload inside Pine Script and pass it as alert_message, then set the alert message box to only that placeholder. Your alert configuration becomes trivial and all the logic lives in version-controlled script.
It also keeps the logic somewhere you control rather than in a vendor's alert configuration, which is the same argument that applies to running the receiving endpoint on self-hosted infrastructure. The trade-off is that string construction in Pine Script is easy to get wrong, and a malformed result silently flips the content type to text/plain. Test the generated string before it points anywhere live.
Mistakes that cost real money
Treating {{close}} as the current price. It is the triggering bar's close. On an intrabar trigger the market has moved since. Using it as a limit price sends orders at a price that no longer exists.
Using strategy placeholders in indicator alerts. They do not resolve, and the literal text usually breaks JSON parsing.
Leaving placeholders unquoted in JSON. If a placeholder resolves to empty, unquoted use produces malformed JSON and the content type changes. Quote them all.
Assuming action alone determines intent. Sell can mean close a long or open a short. Include position context.
Ignoring timezones. Placeholder times are UTC. Market hours are not.
Trusting {{strategy.order.price}} as a fill. It is the simulated fill in the Strategy Tester, not a real execution price. Your actual fill comes from the broker.
The honest limits
Running the receiver on your own infrastructure does not change any of this. Placeholders are text substitution. They carry no validation and no guarantee that a value is sensible — an empty or unexpected resolution produces a malformed payload rather than an error you can catch upstream.
Everything they report about orders and positions describes TradingView's simulation, not your account. Your real position lives at the broker, and reconciling the two is the receiving system's job. A strategy that has drifted out of sync with the account will happily keep sending signals based on a position it thinks it has.
And no placeholder configuration makes a strategy work. Position sizing is what bounds loss — capital divided by twenty as the ceiling per position, under the divide-by-20 rule — and unlike everything on this page it does not depend on a variable resolving correctly.
Frequently asked questions
What are TradingView alert placeholders? Tokens in double curly braces replaced with live values when an alert fires, such as {{ticker}} and {{close}}.
Why do my placeholders show as literal text? Usually a strategy placeholder used in a non-strategy alert, or a typo in the name.
Is {{close}} the current price? No. It is the closing price of the bar that triggered the alert.
What is {{strategy.order.alert_message}}? A placeholder carrying a string built inside Pine Script and passed to the order function, which lets each order generate its own dynamic payload.
How do I tell a close from a short entry? Use {{strategy.position_size}} or the market position placeholders. The action alone does not distinguish them.
What timezone are the time placeholders in? UTC.
Disclaimer: This article is educational content about software engineering and trading automation. It is not investment advice, financial advice, tax advice, legal advice, or a recommendation to buy or sell any security. Any instruments named are used solely to illustrate mechanics. Options trading involves substantial risk of loss and is not suitable for all investors. Please read Characteristics and Risks of Standardized Options before trading options. Automated trading systems carry additional risks including software defects, missed or duplicated signals, network and connectivity failures, third-party service changes and outages, and unintended order behaviour that may prevent orders from being placed, modified, or cancelled. Past performance does not indicate future results, and no configuration, alert setup, position-sizing rule, or risk setting can guarantee a profit or prevent a loss.
StaxInvesting LLC sells self-hosted trading software. It is not a broker-dealer, investment adviser, or financial institution, and it does not manage accounts, hold member funds, place trades on behalf of members, or access member brokerage accounts. Members run the software in their own cloud environment, connect their own brokerage accounts under their own credentials, and are solely responsible for their configuration, their credential security, their compliance with third-party terms of service, and every trade executed in their account. Third-party platform details described here reflect publicly available documentation as of publication and are subject to change without notice; always verify against current official documentation. Consult a qualified financial adviser and tax professional regarding your individual circumstances.