QuantForge
en

How to convert an MT4 Expert Advisor to MT5

Move an MQL4 Expert Advisor to MetaTrader 5: what changes between MQL4 and MQL5, how to convert the source for free, what to check, and how to compare the results.

Start freeRead the docsFree plan, no card needed.

Updated 5 November 2026

MetaTrader 4 and MetaTrader 5 look alike, but their languages differ where it matters for an Expert Advisor: orders, indicators and price data. This guide explains what changes, converts an EA with QuantForge’s free converter, and shows how to check the result.

What changes between MQL4 and MQL5

MQL4 MQL5
Trades Orders, selected with OrderSelect Positions, orders and deals, sent with MqlTradeRequest
Indicators iMA(...) returns a value iMA(...) returns a handle; values come from CopyBuffer
Prices Bid, Ask, Close[1] SymbolInfoDouble, iClose or CopyRates
Inputs extern input (read-only)
Entry points init, start, deinit OnInit, OnTick, OnDeinit
Accounts Always hedging Hedging or netting

Rewriting all of that by hand is where conversions usually break.

Convert the source

  1. Open the MQL4 to MQL5 converter and paste your .mq4 code, or drop the file in the app’s converter.
  2. The converter keeps your code and adds MQL5 versions of the MQL4 functions it calls (OrderSend, OrderSelect, iMA, MarketInfo and the rest). It only rewrites what can’t work that way: price arrays, extern inputs and the old entry points.
  3. Read the notes. Each one has a line number: a custom indicator to convert too, a DLL that must be 64-bit, arithmetic with Period(), error codes that MQL5 numbers differently.
  4. Download the .mq5 (free account), or build the .ex5 directly on Pro.

Compile and compare

  1. Put the .mq5 in MQL5 → Experts, open it in MetaEditor and press Compile. Fix anything the notes pointed out.
  2. In the MetaTrader 5 Strategy Tester, choose a hedging account, the same symbol and dates you used in MetaTrader 4, and the same inputs.
  3. Compare the number of trades, the entry times of the first few trades and the net profit. Small differences are normal (different tick generation and history); different entry logic is not, and the first differing trade shows you where to look.
  4. Run it on a demo account for a while before going live.

Or rebuild it once for both platforms

If you’ll maintain the EA for a long time, rebuild its rules from blocks in the no-code EA builder: one project exports both .mq4 and .mq5, and you can backtest it in the browser.

Frequently asked questions

Can I run an MT4 EA in MetaTrader 5 directly?

No. MetaTrader 5 only runs .ex5 files compiled from MQL5. An MQL4 EA has to be converted to MQL5 and compiled again.

I only have the .ex4 file. Can it be converted?

Not legitimately. A compiled .ex4 holds no source code, and decompiling it is against MetaTrader's terms. Ask the author for the .mq4 source or an MT5 version, or rebuild the strategy from its rules.

Why does my converted EA open fewer trades?

Check the account type first. On a netting account MetaTrader 5 keeps one position per symbol, so an EA that opens several trades on the same symbol behaves differently. Use a hedging account for EAs written for MetaTrader 4.

Build your first EA today

The free plan includes three projects, backtests on H1 to D1 over a year, MQL4/MQL5 export and the converter.

Start free

Keep exploring