How to convert an MT4 EA to MT5
An MT4 Expert Advisor won't run in MetaTrader 5. The two platforms use different languages, MQL4 and MQL5, so 'converting' really means rewriting or rebuilding the EA. Here's what changes and what your options are.
First: what file do you have?
With the .mq4 source code, the EA can be rewritten for MT5. With only a compiled .ex4 file, it can't be converted: there's no readable code inside to work from. In that case your options are the original author, or rebuilding the EA from its rules.
What changes between MQL4 and MQL5
- 1
Orders become positions, orders and deals
MT4 has one pool of orders. MT5 separates pending orders, open positions and executed deals, and accounts can be netting (one position per symbol) or hedging. Every piece of trade-management code has to be rewritten, usually around MT5's CTrade class. - 2
Price arrays disappear
MQL4's ready-made arrays like Close[], High[] and Bars don't exist in MQL5. Prices are read with functions such as iClose() or CopyRates(). - 3
Indicators work differently
In MQL4 you call iMA() and get a value. In MQL5, iMA() returns a handle you create once, then read with CopyBuffer(). Every indicator call in the EA changes shape. - 4
Error handling and order checks
Return codes, filling modes and trade-request checks differ, so logic that 'just worked' in MT4 has to be re-tested in MT5's Strategy Tester.
Your three options
- 1
Rewrite it yourself from the .mq4 source
Realistic if you have the source and know MQL. Plan for a rewrite, not a find-and-replace, and re-test everything. MQL4 vs MQL5 explained. - 2
Hire an MQL5 programmer
The usual route for complex EAs. Give them the .mq4 source and a written description of what it should do. What that typically involves. - 3
Rebuild it from the strategy rules
If you know what the EA does (its entries, exits and risk rules), you don't need the old code at all. Describe the rules in StratoBot and it builds a fresh MT5 EA. How that works.
Quick answers
Can MT5 run MT4 Expert Advisors?
No. MetaTrader 5 only runs MQL5 programs (.ex5). MT4 EAs (.ex4 / .mq4) have to be rewritten or rebuilt for MT5.
Can I convert an .ex4 file to MT5?
No. An .ex4 file is compiled, so there's no code to convert. You need the .mq4 source, or you rebuild the EA from a description of its rules.
Is there an automatic MQL4 to MQL5 converter?
Some converters and compatibility libraries exist and can help with simple code, but order handling, indicator access and price data all work differently in MQL5, so the output still needs to be checked line by line and re-tested.
Give us your trading strategy
Describe it in plain language and see exactly what your bot will do. Free, no account needed.
Build My EAYour first EA is free.