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.
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.
In my case i'm rewritting a MQL4 indicator named ang_DCT:
Now hit the "OK" button and if everything is done, the following message will appear:
After that go to your Metatrader 4 / experts / files folder and you will find the converted mq5 file there:
Now open this file with Metaeditor 5 in compile it:
Try to fix the errors with the MQL4 to MQL5 Porting Table and the last version of the translated MQL5 user guide.
A useful script for changing the timeframe with a hotkey (author - sergeev)
With this little scripts you can change the current timeframe in Metatrader 5 to the previous or next timeframe, for example H1 <- H2 -> H3 with a custom hotkey.
First, place the NextTF and PrevTF scripts in the MetaTrader 5\MQL5\Scripts\ folder:
Then, right click with your mouse on any script and press "Set Hotkey". Now set a custom hotkey that is easy for you to press and to remember. I personally use Ctrl + N for the next timeframe and Ctrl + P for the previous timeframe:
Close the properties windndow and test it out. Cool isn't it? BTW, you can also add a hotkey to the Delete all Objects Script, in my case this is Ctrl + D.
Download the NextTF script
Download the PrevTF script
View the MQL5 source code of the NextTF script
View the MQL5 source code of the PrevTF script
Today we are going to create a simple script for Metatrader 5 that will instantly delete all objects on the active chart window. If you are experimenting with graphical objects or if you are using indicators that do not redraw graphical objects automatically, the script will save your time.
First, open MetaEditor 5 and press the "New" button. The MQL5 Wizard will start up. Select "Script" and press "Next":
Now give a name to your script and fill your copyright information - author and website, then press "Next":
A window with the code for your script will appear. Our script is probably the easiest one, because it contains only one line of code. Add this line of code as shown on the picture:
ObjectsDeleteAll(0);
//---
Now press the "Compile" button and make sure that no errors appear in the debugging window below:
The script is saved in your Scripts folder. Now open Metatrader 5 terminal and add some graphical objects to the chart. Now open the navigator window, select your script and drag it to the chart window. All graphical objects will instantly disappear. It's much faster than doing it by hand, isn't it?
As you can read in the MQL5 reference guide, the ObjectsDeleteAll function removes all objects from the specified chart. You can also specify such variables as chart id, type of object that will be removed, etc. In our case "0" means the current chart. If you want to learn more about this function, search for "ObjectsDeleteAll" in the MQL5 reference guide.
Here i will post all information about Metatrader 5 indicators, scripts and EA's. This post will be regularly updated with links to new content. In the future, i will sort the indicators, scripts and EA's to apart categories.
- MT 5 Indicator Update
- 8 new indicators for Metatrader 5
- Rewrite MQL 4 to MQL 5 Script
- FraMa Cross Indicator and EA for MT5
- Bma and Double Smoothed Stoch Indicators for MT5
- Prev-Next Timeframe Script for MT5
- More indicators for Metatrader 5
- Delete all Objects Script for MT5
- Close All Expert for MT5
- First Metatrader 5 Indicators