Convert Pine Script to MQL5 — TradingView strategies in MetaTrader 5
Prototyped a strategy in TradingView and want to run it — or automate it — in MetaTrader 5? Stratlate is an online converter that translates Pine Script v6 to MQL5: paste your Pine indicator or strategy, click Convert, and get MQL5 source you can compile in MetaEditor. It converts to MQL4 as well if you're targeting older MT4 terminals.
Stratlate is a structural transpiler. It maps the shared core of the two languages — ta.* indicator functions to their i* counterparts, series indexing like close[1] to price-array access, strategy.entry to order-sending logic, plot() to indicator buffers — and it flags, with line numbers, every Pine construct that has no MQL equivalent. Things like request.security() multi-symbol calls or TradingView drawing idioms need a human decision, and Stratlate says so instead of guessing.
Keep in mind the platforms execute differently: Pine evaluates once per bar close, while MT5 runs OnTick() on every tick and executes against a real spread. The converter gives you a skeleton of your logic plus an explicit list of what to verify, and where it can it compares the two scripts' output bar by bar — review and backtest in the Strategy Tester before going live.
To see what the output looks like before pasting your own script, browse the example conversions: public TradingView indicators converted to MQL5 and measured equivalent to the original, with full source on both sides.
Common Pine Script → MQL5 mappings
| Pine Script v6 | MQL5 | Notes |
|---|---|---|
ta.sma(close, len) | iMA(..., MODE_SMA, ...) | ta.ema, ta.rma, ta.wma map to EMA/SMMA/LWMA modes |
ta.rsi(close, len) | iRSI(...) | Direct equivalent |
ta.atr(len) | iATR(...) (not identical) | MetaTrader's ATR averages true range with a simple moving average; Pine's ta.atr uses Wilder's RMA, so the values differ — Stratlate computes the RMA (why) |
ta.bb(close, len, mult) | iBands(...) | Basis/upper/lower become band buffers |
close[i] | close[] series access | Same for open/high/low; indexing direction preserved |
strategy.entry(...) | OrderSend(...) / CTrade | Lot size, slippage and magic number need your values |
close as fill price | Ask / Bid | MT5 fills at bid/ask with real spread — flagged as a warning |
| bar-close evaluation | OnTick() + new-bar guard | A new-bar check reproduces Pine's once-per-bar behavior |
indicator() + plot() | OnCalculate() + buffers | Plots become indicator buffers with SetIndexBuffer |
log.info(...) | Print(...) | Debug output goes to the Experts log |
Need one function rather than the whole table? The Pine Script → MQL5 reference has a page per built-in, and the cheat sheet lists every mapping on one page. For complete indicators on both platforms, see TradingView indicators in MT5.
Convert your Pine Script now
Your first conversion is free, in either direction. Paste your TradingView indicator or strategy and get MQL5 (or MQL4) source — with the constructs it cannot map clearly flagged.
Open the converter