Pine Script strategy alerts for Autoview

Autoview · Guide · Updated July 11, 2026

If you've followed the automate TradingView alerts guide, you've already hand-written a command like s=BTCUSDT b=buy q=1 t=market into an alert's message box. That works fine for a fixed alert. A Pine Script strategy() is different: its buy/sell side and its size can change bar to bar, so a hard-coded message goes stale the moment your logic does. This page covers the other path: having TradingView fill the command in for you.

The piece that makes this work: strategy placeholders

TradingView's alert message box accepts placeholders wrapped in double braces, and it substitutes the real value the instant the alert fires. These are TradingView's substitutions, not Autoview's. Autoview only ever sees the final text after TradingView has already filled it in. Two matter here:

  • {{strategy.order.action}} resolves to buy or sell, lowercase, for whichever order your strategy.entry()/strategy.close() call just placed.
  • {{strategy.order.contracts}} resolves to the size of that same order, as a plain number.

Autoview's parser lowercases every value it reads before matching it, so buy/sell land correctly either way. Drop them straight into the command in place of the values you'd otherwise type by hand:

s=BTCUSDT b={{strategy.order.action}} q={{strategy.order.contracts}} t=market

Set this as the alert's message when you create the alert with condition Any alert() function call on your strategy. Every time the strategy enters or exits a position, TradingView fires the alert with that message, already filled in for the trade that just happened, and posts it to your Autoview webhook.

Symbol still needs a human check

TradingView also offers {{ticker}} for the instrument, but don't reach for it automatically. It returns the exchange's raw concatenated symbol, and that format doesn't match every exchange Autoview supports. OANDA is the sharp case: {{ticker}} returns EURUSD, but Autoview's OANDA parser requires the underscored form, EUR_USD. A command built from {{ticker}} against a forex chart fails silently at the exchange, not at Autoview. Safer default: hardcode s= to the exact symbol your webhook is meant to trade, and only reach for a dynamic ticker once you've confirmed the resolved format matches what your specific exchange expects. The command reference lists the format per exchange.

Layer on risk management the same way

Once the entry/exit side and size are wired up, the rest of the command works exactly like a hand-written one. Stops, targets, and trailing stops attach with the same parameters covered in stops, targets, and trailing, and if your strategy needs to pass a value through that Pine Script computes at the time of the signal (a level, a distance, anything numeric), the custom variables page covers plugging that into the equation side of a parameter without touching the strategy code that generates the alert.

Advanced: passing full commands and computed values through Pine

{{strategy.order.action}} and {{strategy.order.contracts}} cover side and size. Some strategies need more than that in one alert, either a full set of parameters or a number Pine just calculated, like a target price. TradingView has a placeholder for each case.

A whole command, via comment()

strategy.entry(), strategy.exit(), and strategy.order() all take an optional comment argument, a string you write in the Pine code. TradingView exposes that string back to you in an alert message as {{strategy.order.comment}}. Because you control the string, you can put real Autoview syntax in it instead of a plain label:

strategy.entry("Long", strategy.long, comment="b=long")
strategy.exit("Exit", "Long", comment="b=long c=position")

Set the alert message to {{strategy.order.comment}} alone, or mixed into a larger command:

e={{exchange}} s={{ticker}} {{strategy.order.comment}} t=market q={{strategy.order.contracts}}

Whatever you wrote as comment= lands in the message verbatim, and Autoview parses it the same as any other key=value pair. That makes it the tool for a strategy that needs to swap out more than one parameter per trigger, not just the side.

A computed number, via plot()

Pine strategies often calculate a level, a take-profit price, a stop-loss price, anything numeric, and TradingView can hand that number straight to Autoview. Plot it, name the plot, then reference that name in the alert with {{plot("Name")}}:

ftp = close + close * 0.01
fsl = close - close * 0.01
plot(ftp, "Take-Profit")
plot(fsl, "Stop-Loss")
ftp={{plot("Take-Profit")}} fsl={{plot("Stop-Loss")}}

ftp and fsl (Fixed Take Profit and Fixed Stop Loss) are ordinary Autoview parameters; the placeholder just supplies the number instead of you hardcoding it.

Sequencing a split take-profit and stop-loss

Not every exchange accepts a take-profit and a stop-loss at the same moment it opens a position. When a venue won't take both at once, open the position first, then send the take-profit and stop-loss as their own follow-up commands against c=position, and use delay= to hold until the position exists before either one attaches:

e={{exchange}} s={{ticker}} {{strategy.order.comment}} t=market q={{strategy.order.contracts}}
delay=1
e={{exchange}} s={{ticker}} {{strategy.order.comment}} c=position t=market ftp={{plot("Take-Profit")}}
e={{exchange}} s={{ticker}} {{strategy.order.comment}} c=position t=market fsl={{plot("Stop-Loss")}}

The first line opens the position. delay=1 holds for a second so the position exists before the next lines run. c=position tells Autoview this command targets an existing position rather than opening a new one; carrying ftp= or fsl= on that same line turns it into a conditional order, take-profit or stop-loss, attached to that position instead of an immediate close. {{strategy.order.comment}} repeats on every line because Autoview still needs the book (b=long/b=short) to match the follow-up command to the right side of the position. See the delay page for how the pause itself works, and stops, targets, and trailing for sl/tp, the plain (non-computed) versions of the same idea.

Test before you trust it

A strategy alert is still a webhook post, so the same rule applies: dry-run first. Add d=1 to the message, let a few signals fire, and read the log. Did the side and size match what your strategy just did? Did the symbol resolve the way you expected? Confirm both before removing d=1. The automate TradingView alerts guide's dry-run step covers the full round trip if you haven't run through it yet.

A note on what Autoview is. Autoview is an execution tool, not a trading or investment advisor. It places the orders your own strategy and alerts tell it to; it doesn't generate signals or make any claim about results. Trading carries risk of loss, and you're responsible for the strategy you automate. See our disclosures.

Set up your first alert