Automating a TradingView strategy on MT5: how it works and what can go wrong
From TradingView alerts to MetaTrader 5 orders: webhook, message, lot size, broker symbols, and the mistakes that make you miss an entry or an exit.
By Ricardo · Founder of ProTradingLabs6 min read
Your strategy is coded in TradingView, it gives clear signals, and you place your orders by hand on MetaTrader 5. With the delay, the missed signals and the ones at 3 a.m., the idea of automating comes quickly.
It is possible, and simpler than you might think. But between the TradingView alert and the order at the broker, there are four or five steps, and each one can make you miss a trade. Here is how it works, and what can go wrong.
How an alert becomes an order
The path is always the same, whatever the tool:
The TradingView script detects the setup and fires an alert.
The alert sends a text message to a web address, the webhook. This feature requires a paid TradingView plan.
A service receives the message, checks that it really comes from your strategy, and passes it on to your accounts.
An Expert Advisor runs on MetaTrader 5. It receives the signal, calculates the position size and places the order with the broker.
Benjamin Deleuze, trader, mentor and partner of ProTradingLabs, distinguishes the two main ways to automate in a June 2026 interview:
There are two types of automation. There is the automation where you put an expert advisor directly on MT5 and it runs on its own, with a VPS if you want to turn the computer off. […] An indicator you place on TradingView, which sends alerts directly […] to open a position as soon as all the criteria are met on your MT5.
In the first, the whole strategy is coded into the MetaTrader robot. In the second, the strategy stays in TradingView, and the robot only executes. The second is the one we look at here: it lets you keep a Pine script you have already tested.
What the message must contain
The alert message is the only link between TradingView and MetaTrader. It must say, without ambiguity:
- Which position. A unique identifier, repeated identically in every message about it: entry, move to break-even, stop adjustment, exit.
- Which symbol and direction. Buy or sell.
- The entry price and the stop. The stop is essential: it is what gives the position size.
- The target, if there is one.
The classic trap is the identifier. If it is built from the time the alert is sent, it changes as soon as TradingView recalculates the alert, for example when you edit or recreate it. The exit then arrives with an identifier nobody knows, and the position stays open. Build the identifier from the time of the entry candle, which never changes.
Lot size comes from the stop
The TradingView script knows neither your balance nor your broker's point value. So the Expert Advisor calculates the position size, from your risk per trade and the stop distance:
Size = amount at risk ÷ (stop distance × point value)
With no stop in the message, there is no possible position size, and no controlled risk. To choose that risk, see our guide to risk management.
What can go wrong
| Problem | What happens | The fix |
|---|---|---|
| MetaTrader closed or asleep | The signal arrives, nobody takes it | An always-on computer or a remote server (VPS) |
| Different prices | TradingView and the broker do not have exactly the same price | Carry the stop and target distances over from the price obtained |
| Symbol name | US100 on TradingView, NAS100 or USTEC at the broker | A symbol mapping table |
| Identifier that changes | The exit cannot find its position | An identifier taken from the entry candle |
| Entry refused | Lot too small, market closed, risk limit: the exit has nothing left to close | Read the refusal reason at entry, not at exit |
| Broker day change | The spread widens and hits a close stop | Avoid entries just before, or protect the stop at that time |
| Delay | The order goes out a few seconds after the candle | Irrelevant in swing trading, a problem in scalping |
One simple rule follows from this table: when an exit was not executed, look for the reason at the entry. If the entry was never taken on that account, the exit has nothing to close.
Before going live
Test on a demo account, for at least a few weeks, with the same broker as the live account.
Compare every trade on the demo account with the TradingView signals: entry, exit, result. A recurring gap reveals a symbol, price or delay problem.
Check your prop firm's rules, if you have one: Expert Advisors allowed, economic news, weekend positions, daily loss.
Set limits on the account, independent of the strategy: maximum loss per day, maximum open risk. A script that runs wild must not be able to drain the account.
ProTradingConnector: TradingView to MT5, with safeguards
ProTradingConnector, ProTradingLabs' automation tool, opens to the public soon. It links your TradingView alerts to the ProTradingEA Expert Advisor on MetaTrader 5:
- One address and one token per strategy, to paste into the alert. A ready-made text to give an AI helps you adapt your Pine script to the expected format.
- Lot size calculated by the Expert Advisor, from your risk and the stop, with distances carried over from the price obtained.
- Broker symbols found automatically: forex suffixes, and index and oil names (US100, NAS100, USTEC…).
- Every signal tracked, account by account: executed, refused, and why.
- Safeguards per account: daily loss calculated for the worst case, open positions included, a single entry per symbol per day, closing before the weekend and before news releases for prop firm accounts.
Once the trades are executed, you still need to check that they look like the backtest. That is the journal's job: ProTradingData imports your TradingView backtest and syncs the MetaTrader account, to compare the two figure by figure.
To go further: import a TradingView backtest and optimize a strategy without overfitting.
Frequently asked questions
Can a TradingView strategy be automated on MetaTrader 5?
Yes. A TradingView alert sends a message to a web address (webhook); a service receives it and passes it to an Expert Advisor that places the order on MetaTrader 5. Webhooks require a paid TradingView plan.
Do I need to leave my computer on?
MetaTrader 5 and the Expert Advisor must be running when the signal arrives. If the computer is off, asleep or disconnected, the order is not placed. Many traders use a remote server (VPS) for this.
Why does the entry price on MT5 differ from TradingView?
TradingView prices and your broker's prices are never exactly the same, and the order goes out a few seconds after the candle. A good system carries the stop and target distances over from the price actually obtained.
Why was my exit not executed?
Most often because the entry was never taken on that account (EA offline, broker refusal), or because the position's identifier changed between entry and exit, for example when the alert was recreated.
Do prop firms allow this kind of automation?
It depends on the firm and the account type. Many allow Expert Advisors but forbid certain practices (copying between different traders' accounts, latency arbitrage). Check your firm's terms before running a strategy.
Keep reading
ProTradingLabs is not affiliated with FTMO, MetaQuotes, Spotware or TradingView. Trading leveraged products carries a risk of capital loss.