How to automate a TradingView strategy
To automate a TradingView strategy, give each order in your Pine Script strategy an Autoview command, create one alert that fires on the strategy's order fills, and point that alert at your Autoview webhook URL. Every time the strategy fills an order on the chart, TradingView sends that order's command to Autoview, and Autoview places the matching order on your connected exchange. Run it as a dry run with d=1 first, then remove d=1 to go live.
This guide walks you through every step, from a strategy on your chart to a strategy that places real orders on its own. Nothing is skipped, so you can follow it with no setup done yet.
- What do I need before I start?
- Strategy alert or indicator alert?
- Step 1: Give each order its own command
- Step 2: What goes in the alert message?
- Step 3: Where do I get the webhook URL?
- Step 4: Create the alert in TradingView
- Step 5: Run a dry run first
- Step 6: Go live
- Does it have to be TradingView?
- Why did my strategy alert not place an order?
- FAQ
What do I need before I start?
- A Pine Script strategy. That is a script that starts with
strategy(), notindicator(). If yours is an indicator, read the next section first. - A TradingView plan that can send webhooks. As of October 7, 2026, TradingView's plan comparison lists Webhook notifications on Essential and every plan above it (Plus, Premium, Ultimate), and not on the free Basic plan. TradingView's webhook help article adds that webhook alerts are only allowed once two-factor authentication is enabled.
- An Autoview account. Make a free account if you do not have one yet.
- An exchange connected to Autoview. In your Autoview dashboard, open the API Keys page and click Set Up Exchange. The guided setup asks for an API key you create on your exchange. Give that key trading and read access, and leave withdrawals off. The exchange guides show the exact steps for each exchange.
If this is your first automation, connect a demo or testnet account instead of a funded one. Several are free, and you can watch the whole thing work with no real money at stake.
Strategy alert or indicator alert: which one do I use?
TradingView scripts come in two kinds, and they send alerts in different ways.
- A strategy places simulated orders on the chart with calls like
strategy.entry()andstrategy.close(). When one of those orders fills, that is an order fill event, and a strategy alert fires on it. Each order call can carry its own text, so one alert can send an entry command when the strategy enters and a close command when it exits. - An indicator places no orders. It sends alerts through
alertcondition()oralert(), and analertcondition()alert sends the same fixed message every time it fires.alertcondition()compiles inside a strategy, but TradingView does not let you create an alert from it there.
If your script is a strategy, keep going with this guide. If it is an indicator, the automate TradingView alerts guide shows how to write one fixed command into an alert, and Pine Script basics shows alertcondition().
Step 1: Give each order its own command
Open your strategy in TradingView's Pine Editor. Every call that places an order (strategy.entry(), strategy.close(), strategy.exit(), strategy.order() and strategy.close_all()) takes an optional alert_message argument. Put the Autoview command for that order inside it.
Here is a complete example. The moving-average cross is only there so the script has something to trade on. Keep your own entry and exit rules and add alert_message to your own order calls in the same way.
//@version=6
strategy("MA Cross Example", overlay=true)
fastMA = ta.sma(close, 10)
slowMA = ta.sma(close, 30)
if ta.crossover(fastMA, slowMA)
strategy.entry("Long", strategy.long, alert_message="s=BTCUSDT b=long q=1 t=market d=1")
if ta.crossunder(fastMA, slowMA)
strategy.close("Long", alert_message="s=BTCUSDT b=long c=position t=market d=1")Here is what each part of the two commands does:
| Part | What it does |
|---|---|
s=BTCUSDT | The symbol, written the way your exchange writes it. Every exchange spells symbols differently. OANDA, for example, wants EUR_USD, not EURUSD. Copy the symbol from your exchange's own market page. |
b=long | The side. b=long and b=short open a margin or futures position. On a spot pair, use b=buy and b=sell instead. |
q=1 | The size. A plain number goes to the exchange as it is, in that exchange's own order unit: contracts on a futures broker, the coin on a spot pair. Use the smallest size your exchange accepts for now. Always set q. If you leave it off, Autoview uses 100% of your balance. |
t=market | Fill now at the market price. Without it, the order type is limit. |
c=position | On the close line: close the open position on this symbol instead of opening a new one. |
d=1 | Dry run. Autoview reads the command and logs what it would have done, but places nothing. It covers only the line it is on, which is why both commands carry it. |
Give every order call an alert_message. If an order fills from a call that has none, the alert still fires, but with an empty message. To keep an order from sending anything at all, add disable_alert=true to that call.
Save the script and click Add to chart in the Pine Editor, so the strategy is running on the chart of the symbol you want to trade. The command reference explains every parameter above in more detail, and the alert syntax page lists all of them.
There is a second way to do this step: one message with TradingView's {{strategy.order.action}} and {{strategy.order.contracts}} placeholders, filled in for every order. The Pine Script strategy alerts tutorial covers it. This guide uses alert_message because each order carries the exact command you wrote for it.
Step 2: What goes in the alert message?
Only this placeholder:
{{strategy.order.alert_message}}When an order fills, TradingView swaps the placeholder for that order's alert_message text. The entry fill sends s=BTCUSDT b=long q=1 t=market d=1 and the close fill sends s=BTCUSDT b=long c=position t=market d=1. Without the placeholder in the message, your alert_message text is never used.
One rule catches people here. TradingView's other placeholders, such as {{close}}, work in the alert's Message field but not inside alert_message. If a command needs a value the script calculates, build it in Pine. Pine Script alert_message shows how.
Step 3: Where do I get the webhook URL?
The webhook URL comes from Autoview. It is the private address your alert posts to.
- In Autoview, open the webhooks section and create a webhook. Name it after your strategy so you can find it later.
- Open the linkage section, create a link, pick the webhook you just made and the exchange connection you set up earlier, and save. The link tells Autoview which account the commands arriving at this webhook should trade on.
- Copy the webhook URL Autoview gives you.
Keep that URL private. Anyone who has it can send your account a command. For an extra layer, set a key on the webhook and add it to the URL as ?key=yourkey. The webhook key guide covers both ways to send it, and the web platform guide walks through the webhook and link screens in more detail.
Step 4: Create the alert in TradingView
With the strategy on your chart:
- Click Alert (the clock icon) in the right-hand toolbar, or right-click the chart and choose Add Alert.
- In the Condition dropdown, pick your strategy's name, then Order fills only. If your strategy also makes its own
alert()calls and you want those sent too, pick Order fills and alert() function calls instead. - Leave Expiration on Open-ended alert so the alert keeps running.
- In the Message box, delete what is there and paste
{{strategy.order.alert_message}}. - Under Notifications, turn on Webhook URL and paste the URL from Step 3.
- Click Create.
TradingView's Pine Script alerts FAQ names both order fill options. Do not pick an option that covers only alert() function calls: the example script makes no alert() calls, so that alert would never fire.
Step 5: Run a dry run first
Both commands still carry d=1, so nothing reaches your exchange yet. Wait for the strategy to fill an order on a new bar. If you would rather not wait, testing and debugging shows how to force an entry. Check that d=1 is in every alert_message before you force anything, because a forced entry without it places a real order.
When the alert fires, check two places:
- TradingView's alert log shows the message the alert sent. It should be the full command, not the placeholder and not an empty line.
- Your Autoview log shows the command that arrived and the order Autoview would have placed. Check the symbol, the side and the size.
Do this for an entry and for a close. A clean dry run proves your commands parse. It does not prove the whole path to your exchange. Only a live order does that.
Step 6: Go live
- Remove
d=1from everyalert_messagein your script and save it. - Delete the alert from Step 4 and create it again, the same way. An alert keeps a copy of the script from the moment it was created, so editing and saving the script does not change an alert that is already running (see recreate the alert after you change the code).
- Let the first live order be small, just above your exchange's minimum size, or keep the demo or testnet account linked for this run.
- When it fires, confirm the order in three places: TradingView's alert log, your Autoview log, and your exchange's order history.
Change q to the size you actually want to trade only after that round trip looks right. From then on, the strategy places its own orders every time it fills one on the chart, with nothing open on your computer. The webhook runs on Autoview's servers.
Does it have to be TradingView?
No. TradingView is one alert source. Any system that can send a webhook works: Autoview reads the command in the request body, whatever sent it. The web platform guide lists the settings for other senders.
Why did my strategy alert not place an order?
Start with the Autoview log. The usual causes:
- Nothing in the log. The alert never reached Autoview. Check that the Webhook URL in TradingView matches your Autoview URL exactly, including any key.
- The message is empty. The order that filled came from a call with no
alert_message. Add one, then delete and recreate the alert. - The log shows a dry run after you went live. The running alert still has the old script with
d=1. Delete the alert and create it again. - The exchange rejected the order. The log carries the exchange's own response. The usual cause is a symbol in the wrong format or a size below the exchange's minimum.
- The alert never fired. Check the Condition. It has to include order fills.
FAQ
How do I automate my TradingView strategy?
Put an Autoview command in the alert_message argument of each order call in your Pine Script strategy, create one alert on the strategy with the Condition set to Order fills only, set its Message to {{strategy.order.alert_message}}, and paste your Autoview webhook URL into the alert's Webhook URL field. Each filled order then sends its own command, and Autoview places the matching order on your connected exchange. Test with d=1 first.
Which Condition do I pick when I create the alert on a strategy?
Pick the strategy's name, then Order fills only. If the strategy also makes its own alert() calls and you want those sent too, pick Order fills and alert() function calls. An option that covers only alert() function calls never fires for a strategy that makes no alert() calls.
Why did my strategy alert reach Autoview with an empty message?
The order that filled came from a call with no alert_message argument. TradingView replaces {{strategy.order.alert_message}} with an empty string in that case. Give every order call its own alert_message, or add disable_alert=true to the calls that should not send anything.
Which TradingView plan do I need to automate a strategy?
One that can send webhook alerts. As of October 7, 2026, TradingView's pricing page lists Webhook notifications on Essential and every plan above it, and not on the free Basic plan. TradingView's webhook help article adds that two-factor authentication has to be enabled.
A note on what Autoview is. Autoview is an execution tool, not a trading or investment advisor. It places the orders your own strategy tells it to. It does not generate signals, recommend trades, or make any claim about results. Trading carries risk of loss, and you are responsible for the strategy you automate. See our disclosures.