A script which converts MQL 4 code to MQL 5 code was developed by Keiji and Circlesquares on the MQL4 forum.

First, download the following files and place them in your Metatrader 4 / experts / include folder

- mt4accountinfo.mqh
- mt4string.mqh
- mt4datetime.mqh
- mt4objects_1.mqh ( updated version ), see post below.
- mt4timeseries_2.mqh ( updated version ), see post below.

Rewrite MQL 4 to MQL 5 Script

Now, download the latest version of the rewrite script and place it in your Metatrader 4 / experts / scripts folder:

- mq4to5rewrite_sample_v4_2.mq4

After that you will need to place a mql4 indicator, script or ea which you want to convert to MQL 5 in your Metatrader 4 / experts / files folder. Now open Metatrader 4 and run the script. As you can see you must first provide the name (without extension) of your mq4 file and select if it is an indicator (0), EA (2) or script (3) file.

Rewrite MQL 4 to MQL 5 Script

In my case i'm rewritting a MQL4 indicator named ang_DCT:

Rewrite MQL 4 to MQL 5 Script

Now hit the "OK" button and if everything is done, the following message will appear:

Rewrite MQL 4 to MQL 5 Script

After that go to your Metatrader 4 / experts / files folder and you will find the converted mq5 file there:

Rewrite MQL 4 to MQL 5 Script

Now open this file with Metaeditor 5 in compile it:

Rewrite MQL 4 to MQL 5 Script

Try to fix the errors with the MQL4 to MQL5 Porting Table and the last version of the translated MQL5 user guide.

15 comments

Anonymous said... @ December 1, 2009 at 1:34 PM

the updated mt4timeseries.mqh is located at:
http://c.mql5.com/3/2009/11/0/mt4timeseries.mqh

the updated mt4objects.mqh is located at: http://forum.mql4.com/c/forum/2009/10/mt4objects_3.mqh

miranon said... @ December 9, 2009 at 6:06 AM

Thanks for the update Circlesquares!
Great work!

Unknown said... @ December 22, 2009 at 3:51 PM

having issues:
instead of getting the "complete rewriting" the box just disappears?
also in the text above you say "EA = 2"
but in the box it states "1".
i tried both, no luck.
any idea's?

MarlinTrdg said... @ February 4, 2010 at 6:10 PM

Anyone got this to work?

I've tried 3 different MT4 brokers and updated the files but it just keeps saying:
2010.02.04 21:09:32 mq4to5rewrite_sample_v4_2 DJMAR10,H4: Alert: File DowChannelTrader.mq4 not found, the last error is cannot open file

MarlinTrdg said... @ February 4, 2010 at 7:13 PM

Never mind Guys', a clean install with just the new files sorted it..

Arvacon said... @ February 25, 2010 at 3:35 AM

Nice try,it can do the convert from the ex4 files to mq5,but when u want use the files at the mt5,they can not compiled to ex5 files successfully,because of a lot errors that they are creating by the difference of the syntax from the mt4,so you can not use the indicators finally..

Arvacon said... @ February 25, 2010 at 3:41 AM

But this can be very useful for the programmers that they can fix the errors of the indicators and make them work,without need to rewrite an indicator from the begining..

wild raven said... @ March 18, 2010 at 5:15 PM

wouldn't it be nice if there is a sites or programs that help to convert mq4 to mq5 automatically.this is quite challenging for me to do.all we need to do just upload the old mq4 and it do all the troublesome process.

bon bon said... @ July 14, 2010 at 2:29 AM

it's look's like a good script. i was looking a lot for script like this in forex books thank's!

Avdut said... @ October 12, 2010 at 3:06 AM

i m unable to convert indicator..error cannot open file appears
pls help

avd

Avdut said... @ October 12, 2010 at 6:49 AM

hi marlin Trdg,

Can u pls guide how to to do a clean install i tried many ways but was unable to get the file converted ..facing error as file ..the last error is cannot open file"..

pls help

Avdut

robertinno said... @ March 9, 2011 at 8:57 PM

one more mq4 to mq5 converter
http://mq4-mq5.com

cliff said... @ September 22, 2018 at 5:27 PM

Anyone try this last mq4 to mq5 converter? I only want to convert myMT4 to MT5 so I can easily backtest more efficiently. Thanks

TheShalty said... @ November 20, 2019 at 5:21 AM

Hello, I have made an easier way to migrate from MQL4 to MQL5.

I used equality tables and other sources to make "Converter". This software will help you in migrating your experts, indicators and scripts.

For more info visit: https://www.mq4mq5.com/

Regards Shalty




kiku said... @ February 27, 2021 at 12:28 AM

not working its not conwerting nofthing

Post a Comment