You have a Pine Script strategy that backtests well on TradingView and a broker account on MetaTrader 5. The question is how the two meet. There are two genuinely different answers, and they are often confused: you can rewrite the strategy in MQL5 so it runs inside MT5 as an Expert Advisor, or you can keep the strategy on TradingView and route its alerts to an MT5 terminal as trade instructions. The first moves your logic. The second moves only your signals.
Short answer: if your edge depends on tick-level logic, on other MQL5 tools, or you do not want to depend on TradingView at all, rewriting in MQL5 is the right call. If your strategy already lives in Pine Script and you want to keep it there, alert routing is the shorter path, and the piece you then have to keep online is the MT5 terminal, not TradingView. This article walks through what each route actually involves, using one simple rule as the example.

Why these are two different projects, not two settings
MQL5 is MetaQuotes' own language. Its reference describes it as "a high-level language designed for developing technical indicators, trading robots and utility applications, which automate financial trading."[1] An Expert Advisor written in it runs inside the MT5 terminal, reads the broker's price feed, and places orders directly. Nothing from TradingView is involved.
Pine Script, by contrast, runs on TradingView's servers against TradingView's data. Pine cannot place an order at your broker. What it can do is raise an alert, and TradingView can deliver that alert as a webhook, an HTTP POST to a URL you choose.[2] Something at that URL has to turn the message into an order in MT5. That "something" is a connector, and it needs an MT5 terminal that is open and running, because MetaQuotes documents that an Expert Advisor stops when the platform is turned off.[3]
So route 1 is a software port. Route 2 is an integration. They share a broker and nothing else.
The worked example: a two-EMA crossover
Take the plainest rule there is. Go long when the 20-period EMA crosses above the 50-period EMA on the hourly EURUSD chart, with a fixed 0.5 lot size. Close the long when it crosses back below. Here is what you would actually do on each route.
Route 1: rewrite it in MQL5
- Re-implement the indicators. You use MT5's built-in EMA handle or write the calculation yourself, then code the cross detection in an EA's tick or bar handler. Even for a rule this simple, EMA values will differ slightly from TradingView's because the price history and bar boundaries come from your broker's server, not from TradingView's data.
- Backtest again, in MT5. Your TradingView backtest is no longer evidence for this code. The MT5 Strategy Tester runs an Expert Advisor in "a single run with fixed parameters using historical price data" and can optimise across parameter sets, with tick generation modes ranging from "Every tick" to "Open prices only".[4] You are validating a new program.
- Handle order state in code. Position sizing, checking whether a position is already open, and what to do if an order is rejected are now your code's responsibility.
- Host it. The EA runs only while an MT5 terminal is running, so you need a machine that stays on: a PC, a Windows VPS, or MetaQuotes' own MetaTrader VPS, which accepts EAs but not DLL-dependent ones.[5]
- Maintain it. Every future change to the rule is a change to MQL5 code, recompiled and retested. If you also keep the Pine version for charting, you now maintain two codebases that will drift.
Route 2: keep it in Pine and route the alerts
-
Leave the strategy where it is. The Pine
strategy()script keeps running on TradingView, and your existing backtest still describes the logic that will fire. -
Attach an instruction to each order. Pine's
strategy.*()order functions accept analert_messageparameter. TradingView's documentation says that when it is used, "script users must include the{{strategy.order.alert_message}}placeholder in the 'Create Alert' dialog box's 'Message' field when creating script alerts on order fill events."[6] For the EMA example, the entry order's message would be a connector instruction and the exit order's message a close instruction. -
Write the instruction in the connector's format. With PineConnector, that format is one line: LicenseID, Command, Symbol, Parameters, in that order, comma-separated.[7] The entry for our example is
60123456789,buy,EURUSD,vol_lots=0.5and the exit is60123456789,closelong,EURUSD, using the documentedcloselongcommand.[7] The docs also state that entry commands need exactly one volume parameter, and that risk-based volumes such asvol_pct_bal_loss=require a stop-loss parameter, while fixedvol_lots=does not.[7] - Create the alert in the TradingView UI. This step is manual by design. The Pine documentation is explicit that "no alert-related Pine Script code can create a running alert in the charts UI; it merely creates alert events which can then be used by script users to create running alerts from the charts UI."[6] You set the webhook URL in the alert dialog.[2]
- Keep one MT5 terminal running with the connector EA attached. This is the always-on component. It can be your own Windows machine or VPS, or a hosted terminal. TradingView delivers the webhook and cancels the request if the receiver takes more than three seconds,[2] so the receiver's job is to accept quickly and hand the instruction to the terminal.
Two behaviours of route 2 catch people out and are worth knowing before you start. First, TradingView keeps a snapshot: creating an alert "saves a 'snapshot' of the script, its inputs, and the current chart's context on TradingView's servers", and to update it you must "delete the existing alert and create a new one."[8] Editing your Pine code does not change a live alert. Second, TradingView warns not to include "sensitive information such as login credentials or passwords in the webhook body."[2] A connector should identify you by a licence or key, never by your broker password.
Side by side
| Route 1: rewrite in MQL5 | Route 2: route the alerts | |
|---|---|---|
| Up-front effort | Port the strategy, re-implement indicators, handle order state | Add alert messages to existing orders, create the alerts, install or activate a connector |
| Where backtests live | MT5 Strategy Tester, on broker data | TradingView, on TradingView data |
| Who maintains the logic | You, in MQL5 | You, in Pine Script |
| Depends on TradingView | No | Yes, for signals |
| Needs an always-on MT5 terminal | Yes | Yes |
| Tick-level or sub-bar logic | Available | Limited to what Pine alerts can express |
| Cost shape | Your time, plus hosting | Connector subscription, plus hosting unless included |
Who should rewrite in MQL5
- Your logic needs the tick stream or broker-side data that Pine alerts cannot carry, such as reacting to spread, order book depth, or partial fills.
- You rely on the MQL5 ecosystem: other Expert Advisors, custom libraries, or the Strategy Tester's optimiser as your primary research tool.
- You do not want a TradingView dependency. If TradingView is down or your subscription lapses, an MQL5 EA keeps trading.
- You are comfortable in a C-like language and want to own every line between signal and order.
For these traders, a connector is the wrong tool, and no hosting product changes that.
Who should route the alerts
- Your strategy already exists in Pine and you trust the backtest you have, as evidence about the logic rather than about future results.
- You want one codebase, edited in one place, with the chart and the live signal always in agreement.
- You need the same signal on several accounts, since one alert can be routed to more than one terminal.
- You would rather not learn MQL5 to trade a rule you have already written.
Where PineConnector fits on route 2
PineConnector is a connector for route 2. Your Pine strategy stays on TradingView, each order's alert_message carries a one-line instruction in the documented format, and PineConnector's Expert Advisor in an MT5 terminal turns it into an order at your broker. The step-by-step setup guide covers installing that EA on your own Windows machine or VPS.
The always-on terminal is the part most people underestimate. PineConnector Edge is "managed MT5 hosting included in every PineConnector plan": PineConnector runs the MT5 terminal with its connector on its own infrastructure, and you control it from the web portal.[9] It is "managed infrastructure, not managed execution", meaning your broker account, your strategy and every trading decision stay yours.[9] Plans are Core at $59 a month with one connection and one hosted MT5 instance, Plus at $129 with three, and Pro at $199 with five; instances run in New York, with London coming soon for Plus and Pro.[9]
The boundaries matter here, because they are exactly what separates the two routes. The Edge Guide states that "Edge does not support custom or other third-party EAs. If your setup requires additional EAs, use PineConnector on your own computer or VPS."[10] It is MT5 only, it is currently in early access, and during early access the EA settings "use a fixed default configuration and cannot be edited", with customisation planned for a later update.[10] So an MQL5 EA you wrote yourself, route 1, cannot run on PineConnector Edge. If that is your route, you host it yourself. For a plain overview of the hosted option, see what PineConnector Edge is or the Edge page.
Frequently asked questions
Can I convert Pine Script to MQL5 automatically?
No tool we would rely on. The two languages model time, data and orders differently, and MT5 uses your broker's price history rather than TradingView's. Treat any conversion as a rewrite that needs its own backtest in the Strategy Tester.[4]
If I route alerts, does my TradingView backtest prove the live result?
No. It describes the logic, and route 2 keeps that logic unchanged. Live fills, spreads and slippage at your broker are different from the backtest engine, and past performance does not indicate future results on either route.
Why did my alert keep using the old settings after I edited the script?
Because alerts are snapshots. TradingView's own FAQ says the alert saves the script, its inputs and chart context at creation time, and that you must delete and recreate the alert to pick up changes.[8] No connector or hosting product can change an upstream alert.
Can I run my own MQL5 Expert Advisor on PineConnector Edge?
No. The Edge Guide states that third-party or custom EAs are not supported and points those users to running PineConnector on their own computer or VPS.[10]
Next step: if you are taking route 2, read the TradingView to MT5 setup guide and decide whether you will host the terminal yourself or use PineConnector Edge. If you are taking route 1, start with the MQL5 reference and the Strategy Tester documentation linked below.
Reviewed 9 September 2026. Facts and prices were checked against the linked sources on that date.
Sources
- MetaQuotes – MQL5 Reference, accessed 9 September 2026.
- TradingView Help Center – How to configure webhook alerts, accessed 9 September 2026.
- MetaQuotes – MetaTrader 5 Help: Algorithmic Trading, accessed 9 September 2026.
- MetaQuotes – MetaTrader 5 Help: Strategy Testing, accessed 9 September 2026.
- MetaQuotes – Rules of Using the Virtual Hosting Service, accessed 9 September 2026.
- TradingView – Pine Script documentation: Alerts, accessed 9 September 2026.
- PineConnector Docs – Syntax, accessed 9 September 2026.
- TradingView – Pine Script FAQ: Alerts, accessed 9 September 2026.
- PineConnector – PineConnector Edge: Managed MT5 Hosting, accessed 9 September 2026.
- PineConnector Docs – PineConnector Edge (Early Access), accessed 9 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.