Skip to content

How to use plot placeholders with TradingView's strategy alerts?

How to use plot placeholders with TradingView’s strategy alerts?

Section titled “How to use plot placeholders with TradingView’s strategy alerts?”

TL;DR
Name the plots that contain the data you want, then reference them in alert messages using {{plot("Plot Name")}}; TradingView swaps the placeholder for the current plot value at trigger time.

DifficultyBeginner
Time to implement10-15 min
CategoryAlerts
//@version=5
strategy("Placeholder demo", overlay=true)
stopLevel = ta.lowest(low, 10)
targetLevel = ta.highest(high, 10)
plot(stopLevel, "Stop")
plot(targetLevel, "Target")
//@strategy_alert_message Stop: {{plot("Stop")}} | Target: {{plot("Target")}}
Tip. Plot names are case-sensitive. Check the Data Window (⌘+I / Ctrl+I) to confirm each plot’s exact title before referencing it in `{{plot("…")}}`.

Alerts that include live price levels remove guesswork—trade management levels arrive with every notification. Plot placeholders are the simplest way to achieve that: expose the numbers via plot, then pull them into alert messages without extra state management or custom strings.

  • Publish the required values via plot so TradingView can surface them in alerts.
  • Reference those plots with the {{plot("Name")}} placeholder syntax.
  • Provide a default alert body using //@strategy_alert_message, or type placeholders manually when creating alerts.
  • Validate the output to ensure rounding, formatting, and precision meet your needs.
CallPurpose
plot(series, title)Exposes a value that placeholders can reference.
{{plot("Name")}}Inserts the latest value of the plot named Name into an alert.
//@strategy_alert_message ...Sets the default alert message for the strategy.
alertcondition(condition, title, message)Optionally pair placeholders with indicator-style alerts.
tostring(value, format)Use inside labels if you also display the value on-chart for verification.
  1. Publish the values via plots
    Plot every number you want to include in alerts and give each plot a unique, descriptive title.

    stop = ta.lowest(low, 14)
    limit = ta.highest(high, 14)
    plot(stop, "Stop price")
    plot(limit, "Target price")
  2. Reference plots in the alert message
    Use //@strategy_alert_message to define a default message, or type placeholders manually when creating an alert.

    //@strategy_alert_message Stop: {{plot("Stop price")}} | Target: {{plot("Target price")}}
  3. Create the alert (and test)
    Add the strategy to a chart, open Create Alert, and confirm the placeholders resolve correctly. Trigger a test alert to validate formatting.

//@version=5
strategy("Breakout with dynamic alert", overlay=true, pyramiding=0)
len = input.int(20, "Lookback")
bufferTick = input.int(2, "Buffer (ticks)")
float tickToPrice(int t) => t * syminfo.mintick
rangeHigh = ta.highest(high, len)
rangeLow = ta.lowest(low, len)
stopLevel = rangeLow - tickToPrice(bufferTick)
targetLevel = rangeHigh + tickToPrice(bufferTick * 2)
plot(rangeHigh, "Range high")
plot(rangeLow, "Range low")
plot(stopLevel, "Stop level")
plot(targetLevel, "Target level")
longBreakout = ta.crossover(close, rangeHigh)
shortBreakout = ta.crossunder(close, rangeLow)
if longBreakout
strategy.entry("Long", strategy.long)
if shortBreakout
strategy.entry("Short", strategy.short)
//@strategy_alert_message {{strategy.order.action}} {{strategy.order.contracts}} @ {{strategy.order.price}}\nStop: {{plot("Stop level")}} | Target: {{plot("Target level")}}
Why this works.
  • Plots expose every relevant level so placeholders can pull them into alerts.
  • The default alert message combines built-in strategy variables (`strategy.order.*`) with custom plots for full context.
  • Tick buffers show how to prepare values that need minor adjustments before plotting.
  • Placeholders resolve to raw numbers. If you need formatting (e.g., two decimals), use Alert formatter rules in the UI or round the plotted series beforehand.
  • The alert message runs once when the alert is created. Updating the script (or changing plot names) requires recreating the alert so placeholders stay in sync.
  • Strategy placeholders support both plots and built-in variables such as {{strategy.order.contracts}}. Mix and match for richer notifications.
  • Indicator alerts work the same way—just ensure the indicator also exposes the series via plot.

The plot returned na on that bar. Guard the plotted series (e.g., plot(condition ? value : na)) so placeholders only fire when meaningful data exists.

Double-check spelling and case sensitivity. The placeholder must match the plot title exactly, including spaces and capitalisation.

Can I include multiple plots in one placeholder?

Section titled “Can I include multiple plots in one placeholder?”

No—use separate placeholders (e.g., Stop: {{plot("Stop")}} | Target: {{plot("Target")}}). Each resolves independently when the alert triggers.

  • Plot placeholders bridge your chart logic with alert notifications—all you need is a named plot and a matching {{plot("Name")}} reference.
  • Define a default alert body with //@strategy_alert_message so every alert includes the dynamic values automatically.
  • Validate the final alert output with a quick test trigger to confirm formatting and precision.
  • Keep plot titles stable; renaming them requires updating every placeholder that references them.

Adapted from tradingcode.net, optimised for Algo Trade Analytics users.