Convert MQL4 to MQL5

MetaTrader 4 to MetaTrader 5. Paste or upload an MT4 Expert Advisor or indicator and get it back as MQL5 for MetaTrader 5 (.mq5), with a report on every part of it: what converted exactly, what had to change for MT5, and what couldn't be converted.

AI-converted code to review: compile it in MetaEditor and test it in the Strategy Tester and on a demo account before you rely on it.

How it works

  1. Paste or upload your .mq4 — An Expert Advisor or a custom indicator, old start() style or new. Say which it is: each has its own conversion rules. We keep the MQL5 version and its report, not your MQL4 code; it's only sent to our AI provider to convert it.
  2. The AI rewrites it in MQL5 — Orders become MT5 positions and CTrade calls, indicator calls become handles, and every MQL4-only function is replaced, while your inputs, signals, stops and lot sizing stay as they are.
  3. Read the report, then compile — Every part of the code is marked as the same as MQL4, changed, or not converted, with the reason. Download the .mq5, compile it in MetaEditor and test it. If MetaEditor shows errors, paste them and our EA fixer corrects the file.

Why not just use ChatGPT?

Generic AI gives you code and leaves you alone. We fix it if it breaks.

Generic AI chatbot: Gives you code and leaves you alone. If it breaks, you're on your own. No real developer to turn to.

PositionAlpha: AI builds it, and you see a preview first. AI revisions in plain English. A real MQL5 developer fixes it, at no extra cost.

ChatGPT is a trademark of OpenAI. We are not affiliated with OpenAI.

Developer Fix Guarantee

AI builds it. Real MQL5 developers make sure it works.

If your converted file doesn't compile or doesn't do what you approved, one of our developers fixes it by hand, at no extra cost. We reply within 24 hours, and if we can't fix it, you get your money back.

Our developers have built 300+ trading bots for prop firms and hedge funds.

We guarantee working code that follows your rules, not trading profits. No bot is guaranteed to make money, and trading can lose money.

See exactly what changed

Sample report: MA Cross EA.

  • Same as MQL4: extern double Lots = 0.1; extern int StopLoss = 50 → MT5 inputs, same names and defaults
  • Same as MQL4: iMA(NULL, 0, FastMA, 0, MODE_EMA, PRICE_CLOSE, 1) → iMA handle read with CopyBuffer
  • Same as MQL4: OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, sl, tp) → CTrade.Buy with the same stops
  • Same as MQL4: for (i = OrdersTotal() - 1; i >= 0; i--) OrderSelect(...) → Loop over positions by symbol and magic
  • Same as MQL4: OrderModify(..., newStop, ...) trailing stop → CTrade.PositionModify
  • Changed: Buy and sell open at the same time → Separate positions. Works the same on a hedging account. On a netting account MT5 merges them into one position, so the EA warns you when it starts.
  • Changed: if (Period() == 60) → PeriodSeconds() == 3600. MT5's time frame values aren't minutes, so the check compares seconds instead.
  • Not converted: FileWrite(handle, ...) trade log. File access isn't included in converted code. The Experts tab shows each trade instead.
  • Hedging or netting account. The EA can hold a buy and a sell at once, which needs a hedging account in MetaTrader 5. Check your account type with your broker.

What it converts

  • Expert Advisors and custom indicators, in the old start() style or the new OnTick and OnCalculate style
  • Inputs, with the same names, defaults and labels
  • Orders and order loops, as MT5 positions, pending orders and CTrade calls
  • Stops, targets, trailing stops, break-even and lot sizing, with the same rules
  • Built-in indicators (iMA, iRSI, iMACD and the rest), as MT5 indicator handles
  • Indicator buffers, styles, arrows and levels, keeping the buffer numbers EAs read
  • Chart objects, comments and alerts

What it changes or leaves out, and tells you

  • Hedging logic on a netting account: MT5 merges trades on the same symbol
  • Custom indicators your EA reads with iCustom: you need their MQL5 versions too
  • DLL imports, web requests and file access: left out of converted code
  • Include files that weren't in your upload
  • Bugs and risks kept from the original, such as a missing stop loss or a martingale

Why MQL4 to MQL5 conversions go wrong

MQL5 looks like MQL4, but most of what an EA does works differently underneath. A find-and-replace port rarely compiles, and one that compiles can still trade differently. These are the usual reasons:

Orders became positions

MT4 has one list of orders. MT5 splits it into open positions, pending orders and deals in the history, so every OrderSelect loop has to be rewritten.

Indicators return handles

In MQL4, iMA gives you a value. In MQL5 it gives you a handle that you create once and read with CopyBuffer, and some line numbers (Ichimoku, Alligator, Envelopes) are counted differently.

Hedging and netting accounts

An EA that holds a buy and a sell at once works on an MT5 hedging account, but on a netting account the two merge into one position.

Time frames aren't minutes

Period() returns 60 for H1 in MT4 and 16385 in MT5. Code that does arithmetic with time frames or compares them with numbers breaks quietly.

Bid, Ask and Close[] are gone

MQL5 has no predefined price variables or arrays. Prices have to be read when they're needed, and bar data with functions like iClose.

Indicator buffers start empty

MT4 fills new buffer values with an empty value; MT5 doesn't, which leaves stray lines and arrows unless every bar is written.

The converter is built around these differences, and its report tells you where the MQL5 version can still differ.

Pricing

Converting an EA or indicator is free to try: you see the report and a preview of the code. You pay once to download the .mq5 file, and the price is shown before you pay. Bot Studio is pay per build: building and previewing a bot, an indicator or a conversion is free, and you pay once to download it. Each of those purchases includes AI revisions and a fix by a professional MQL5 developer. No subscription.

Build MT4 and MT5 trading bots with PositionAlpha

Questions

What if the AI code doesn't work?

If your converted file doesn't compile or doesn't do what you approved, one of our developers fixes it by hand, at no extra cost. We reply within 24 hours, and if we can't fix it, you get your money back. We guarantee working code that follows your rules, not trading profits.

Can it convert Expert Advisors as well as indicators?

Yes. Pick Expert Advisor or Indicator before you convert: each has its own conversion rules. Scripts and libraries on their own aren't converted yet.

Will the MQL5 file compile?

The AI is told to write code that compiles in MetaEditor on the first try and to follow MQL5's rules, but PositionAlpha doesn't compile or test the code. Compile it yourself in MetaEditor. If it shows errors, paste them on the result page for an AI revision, or request a developer fix.

Will my EA trade the same way in MetaTrader 5?

It's written to keep the same signals, orders, stops, lot sizing and exits. Differences can come from your account type (hedging or netting), your broker's prices and execution, and from what MetaTrader 5 does differently. The report lists every difference the AI knows about, so test both side by side in the Strategy Tester and on a demo account before using real money.

Does it change my strategy or fix its bugs?

No. It converts what your code does, settings included, so the MQL5 version behaves like the original. Bugs and risks it notices, such as a missing stop loss, are kept and listed in the report. To change or fix the EA, use our EA fixer after converting.

My EA uses a custom indicator. What do I need?

MetaTrader 5 can only load MQL5 indicators, so you need the .mq5 or .ex5 version of every custom indicator the EA reads. If you have its .mq4 source, convert it here as an indicator first.

Can it convert .ex4 files?

No. A compiled .ex4 file can't be read or converted. You need the .mq4 source file.

Do you keep my MQL4 code?

No. PositionAlpha keeps the MQL5 version and its report in your account, not your MQL4 code. The code is sent to our AI provider to convert it.

How much does it cost?

Converting and previewing is free. Downloading the .mq5 file is a one-time payment, shown before you pay, and it includes AI revisions and a fix by a professional MQL5 developer. We guarantee working code that follows your rules, not trading profits.

MetaTrader, MQL4 and MQL5 are trademarks of MetaQuotes Ltd. PositionAlpha isn't affiliated with MetaQuotes.