Installing an MQL4 program


Hi folks,

One of the most important features of MetaTrader is the ability to write your own programs and attach them to MetaTrader terminal. Programs includes Indicators , Expert advisors , Scripts and Libraries. These programs written in a programming language called MQL4 and can be used in MetaTrader by proper installing.

Today we are going to study how to install these program to use them in MetaTrader.

Format:

There are two kinds of files that you'll use with MetaTrader; the programs files and the executables files.The program files are normal text files but have one of these extensions: .mq4 and .mgh.
These files are the source code of the programs wrote in MQL4 programming language; source code means they could be opened for viewing or editing.

You open these files with a program shipped with MetaTrader called MetaEditor.
MetaEditor is the program enabling you to view, edit and compiling these files (we are going to know what compiling means).

The executable files are binary files (you can't open them for viewing or editing) and has the extension .ex4. These files are the result of compiling the .mq4 files using MetaEditor. And these are the files that you can load them in MetaTrader and use them.

Note: the .mgh files are header files which mean they have line of codes and the MQL4 programmer can include them in his MQL4 programs. So they couldn't be compiled to .ex4 files.

Compiling:

Compiling is an operation taken by a special program (called a compiler) to convert from text (readable) format to the binary format which the computer can understand (computers think in binary).
This is the general definition of compiling. Compiling in our case is converting the mq4 files to ex4 for file using MetaEditor program.
To do that we simply open the mq4 files in MetaEditor then pressing F5 hot key. MetaEditor will compile (convert) the file to ex4 format and keeping the mq4 file untouched.
MetaEditor will place the generated ex4 file at the same path as the mq4 file.

We compile the mq4 files because the MetaTrader can't load any files except ex4 files. So, when we get the mq4 files and compile them, does it mean we've finished installing them and ready to use them? Actually no! There's a further step we have to take. This step is putting the ex4 file in its proper folder.

Note: it's recommended to take the folder step before the compiling step that's because the compiler will place the ex4 file at the same place as the mq4 files.

Folders:

You knew that there are four kinds of MetaTrader programs; expert advisors, indicators, scripts, libraries, besides the header files (.mgh files).
MetaTrader is very tidy program and he set a folder for each type of programs and he expects that you are a tidy trader and will place every program in its proper folder.
MetaTrader search the folder of the experts for the experts and the folder of indicators for the indicators etc.
And MetaTrader only interested in the ex4 files and they are the files he searches the proper folders for!

So, you have to place the source code of the expert advisors in the folder of the expert advisors and use MetaEditor to compile them to generate ex4 files in the expert advisors folder. The same with the indicators, the scripts and the libraries.

These are the folders used:

Expert advisors folder:
MetaTrader_Dir\experts

Indicators folder:
MetaTrader_Dir\experts\indicators

Scripts folder:
MetaTrader_Dir\experts\scripts

Libraries folder:
MetaTrader_Dir\experts\libraries

Include folder (mqh files):
MetaTrader_Dir\experts/include

I hope installing MetaTrader programs now is an easy task and if you have any question please don't hesitate to ask!

Coders Guru!

Do You Like this Article?