How to Convert an MT4 EA to MT5 (and Why Converters Fail)
Short answer: you cannot run an MT4 Expert Advisor on MT5 — .ex4 files only
load in MetaTrader 4. Converting means rewriting the MQL4 source as MQL5: trade
handling, indicator access and account logic all change, not just names. With
the source you can rewrite or convert it; without the source you must rebuild the
strategy from its rules. Either way, backtest the MT5 version from scratch.
Why an MT4 EA does not "just work" on MT5
MetaQuotes built MT5 on a different language. Programs written for one do not compile in the other, and compiled files are not interchangeable. The differences that matter most for an EA:
| Area | MQL4 | MQL5 |
|---|---|---|
| Opening a trade | OrderSend(...) returns a ticket | CTrade.Buy() / OrderSend(request, result) |
| Open trades | One mixed list of orders | Positions, orders and deals are separate |
| Indicators | iRSI(...) returns a value | iRSI(...) returns a handle; values come from CopyBuffer |
| Prices | Bid, Ask variables | SymbolInfoDouble(_Symbol, SYMBOL_BID) |
| Account | AccountBalance() | AccountInfoDouble(ACCOUNT_BALANCE) |
| Errors | GetLastError() codes | Trade result retcodes plus error codes |
| Position model | Many trades per symbol | Netting (one per symbol) or hedging, by account |
The dangerous differences compile cleanly. MT4 numbers some indicator lines from 1
(Alligator, Fractals, Envelopes, Ichimoku, Gator) where MT5 numbers every buffer
from 0, and iBands takes its arguments in a different order. A mechanical
conversion that misses either trades on the wrong line with no error.
The full list is here.
Netting versus hedging
When MT5 launched it only supported netting — one position per symbol, with new trades adding to or reducing it. MT4-style strategies that hold several trades at once only behave the same on an MT5 hedging account, which brokers now widely offer. Check which your account is before judging a converted EA: the same code behaves differently on each.
Your options
You have the .mq4 source
- Rewrite by hand (or pay a developer to). Most reliable for complex EAs.
- Use a converter or compatibility library. These map MQL4 calls onto MQL5 equivalents and can get simple EAs compiling. They struggle with order loops, position logic and anything that assumes MT4's single order list.
- Ask an AI to convert it. Helpful as a first draft; check every trade call and indicator read — the mistakes are the ones above, and they compile.
You only have the .ex4
You cannot convert a compiled file. Rebuild the strategy from its rules: the vendor's documentation, its inputs, and its trade history in a backtest tell you most of what it does. If you bought it, ask the vendor for an MT5 version first.
The rebuild route: platform as a setting
If you rebuild a strategy as a graph, the platform stops being a rewrite. In
TradeSmithy, a project targets MT4 or MT5, and switching it changes nothing on the
canvas — it re-checks the graph against the new platform and exports the other
language, generated by a separate MQL5- or MQL4-specific generator rather than a
find-and-replace. Every indicator MT4 ships also exists on MT5, so an MT4 graph
moves to MT5 cleanly; the one thing to replace is any custom indicator, whose
.ex4 needs its .ex5 equivalent — the builder flags it on the node and refuses
to export until it is fixed.
Retest after converting — always
A converted EA is a new EA. Even perfectly translated logic meets different history, a different tester and possibly a different position model. Run it in the MT5 Strategy Tester — step-by-step guide — compare the trade list with the MT4 version over the same dates, and explain every difference before trading it.
Rebuild once, export to both
Start free on TradeSmithy, rebuild the strategy on the canvas, and export it as MQL5 — or MQL4, from the same graph — with one export a month free. On Pro, describe the old EA's rules to the AI assistant and let it build the first draft of the graph. Background: how to create an MT4 EA without coding.
Frequently asked questions
Can MT5 run MT4 Expert Advisors?
No. MT5 only runs .ex5 files compiled from MQL5 source.
Is there a free MT4 to MT5 EA converter?
Converters and compatibility libraries exist and help with simple EAs. Anything with order management usually needs manual work and a full retest.
Can I convert an .ex4 file to MT5?
Not directly. Without the source code, the strategy has to be rebuilt from its rules.
Why does my converted EA behave differently on MT5?
Usually the position model (netting vs hedging), indicator line numbering, or different historical data. Compare trade lists to find which.
Keep reading
Indicator to EA: Turn Any MT4/MT5 Indicator Into a Robot
Turn a built-in or custom indicator into an Expert Advisor without code — reading buffers, arrow indicators, the repainting trap, and what a converter can't do.
4 min readMQL4 vs MQL5: what actually changes when you switch platform
MQL5 is not MQL4 with a bigger version number. Orders, indicators, buffer numbering and even argument order differ — and the worst differences compile cleanly.
4 min readConvert a TradingView Strategy to an MT5 Expert Advisor
Two ways to take a Pine Script strategy to MetaTrader 5 — a webhook bridge or a native rebuild — what each costs, and why results never match exactly.
4 min read