SE supports several dozen languages, but allows you to add custom languages as well.
In my opinion, it is more convenient to bind MQL4/5 to any of the standard set of languages instead of creating a new custom language. This is because mqh files are used in both MQL4 and MQL5 and each language should have unique extension combinations. If we create MQL4 and MQL5 languages, then one of them will be left without mqh files.
But it is possible to create several highlighting profiles for one language, that is what we will do. The most logical and correct way is to link to C/C++ and we will do so, i.e. link MQL4 and MQL5 to C/C++ and create appropriate highlighting profiles. Then we won't have any problems with mqh files.
For SE to recognize mqh, mq4 and mq5 files, these extensions must be prescribed in the settings. You can enter here:
Go to Languages->Application Languages->C/C++->General.
Press Edit These Extensions... button.
In the window that appears enter our extensions.
Now, when you open documents mqh, mq4, mq5, the code will be highlighted by the C/C++ syntax.
The next step is to set the syntax highlighting separately and specifically for our favorite languages MQL4 and MQL5.
Before setting up the syntax highlighting separately for MQL4 and MQL5 we need to configure the styler. When switching between MQL4/5 highlighting profiles, the highlighting does not change immediately, as it is necessary to reread the highlighting settings. For the highlighting profile to take effect after switching, you must either re-open or open the file. Or use a styler, which automatically re-reads the highlighting file and creates a variable cache for the edited file for correct highlighting.
So, the styler is set up like this:
Go into:
Or, you may do another way, and open any file with extension mqh, mq4, mq5 as follows:
To avoid going to the menu for the styler every time, let's place the button on the toolbar:
After that a toolbar with the styler button we need appears:
The panel, of course, can be moved wherever is more convenient:
Let's create a highlighting profile for MQL4.
To do this, go here:
And manually type in all MQL4 keywords (or read the next steps of the instructions, where there will be a ready-made file with all settings that can be imported).
Just like in the previous step, create a highlighting profile for the MQL5 language.
In SE we can work in 1) edit one file or in 2) project mode.
1) Variables and functions declared in inludes (if they are attached to the file being edited) will not be visible, with the inconvenience this causes, but such a single opened file can be compiled.
2) The project mode doesn't have the inconvenience of editing a single opened file.
To begin with, we will set up SE to work in single file editing mode.
Let's connect the MQL4 compiler for working in the single opened file editing mode.
To do this, switch to the MQL4 highlighting profile.
Open a file with mq4 extension.
Go here:
Do as shown in the screenshot below:
Now let's connect the MQL5 compiler to work in single-open file editing mode.
To do this, we switch to the MQL5 highlighting profile.
Open a file with mq5 extension.
Go to the dialog window in the same way as when setting up the MQL4 compiler.
Do as shown in the screenshot below:
So, in order to work in project editing mode, you should first create appropriate project types.
Let's create the MQL4 project type.
Go here:
Please note that you have not yet highlighted in red (it will appear later, when the appropriate types of projects will be created).
Click on Customize...
Click New
Then a dialog box will open where you should do as in the screenshots below:
The same thing should be done for MQL5 projects.
Now let's create MQL5 project (we will skip MQL4 project creation, as the procedure is the same as for MQL5 project creation).
Go to Project menu and select New...
Choose the MQL5-type project from the list. Specify the project name "Sample". Specify the location of the project file and press Ok. Do as shown in the screenshot for example:
As the ...\Sample folder does not exist at the specified path, you will be offered to create the folder or skip it. We accept.
A window will appear where we may customize the project created using the previously selected template.
In the tab Files it is possible to add source files of our project, but we will not add anything yet:
The Tools tab contains the compiler settings. If it doesn't look like in the screenshot below, it means that something was done wrong when creating a template like MQL5 project. You can cancel the project creation and return to the previous steps to correct the template. Or set up the project now in the window:
Nothing more in this window is necessary to us, and we press Ok.
That is all. The MQL5 project has been created. So far, it is empty and the source code files are not connected/created.
Now, in any (does not matter) of the folders of the project (these folders are virtual, they are not) create new and select existing source code files.
This is basically all you need to know and be able to use SE to edit and compile MQL4/5 programs.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good afternoon, colleagues.
I have been approached by forum members with a request for help with the settings of the above-mentioned editor. Although there is a lot of material on this topic on the web, programmers still have problems with the settings. I will show you how to do it step by step.
The MetaEditor is a great editor and it is capable of satisfying the needs of most programmers. However, it is not powerful enough to manage very large projects of tens of thousands of lines with many inludes. Therefore, I ask the administration to be sympathetic to this thread.