Welcome to the MQL4 course.
In this series, I will try to strip the mystique and confusion from MQL4 by giving you comprehensive tutorials with a straight forward example.
In this series of lessons, I will show you how to use the MQL4 for building your own Expert Advisors, Custom Indicators and Scripts.

If you are programming in C (or its superset C++) then you know a lot of MQL4 before even I start my lessons, if you didn’t write in any programming language before, no problem, I’ll guide you to understand the concept of programming in general as well.
So, let’s start from the beginning.
MQL4? What, Why and Where?
MQL4 stands for MetaQuotes Language 4.
MetaQuotes is the company who built the MetaTrader Trading Platform.
And to make it stronger than the other trading platforms the company extended it by a built-in programming language that enables the user (you) to write his own trading strategies.
The language enables you to create one of the following:
1- Expert Advisors.
2- Custom Indicators.
3- Scripts.
• Expert Advisor is a program which can automate trading deals for you. For example it can automate your market orders, stops orders automatically, cancels/replaces orders and takes your profit.
• Custom Indicator is a program which enables you to use the functions of the technical indicators and it cannot automate your deals.
• Script is a program designed for single function execution. Unlike the Advisor, scripts are being held only once (on demand), and not by ticks. And of course has no access to indicator functions.
These were “What” MQL4 is? “Why” to use MQL4?
Now, “Where” do I write MQL4?
To write your MQL4 code and as anything else in world, you can choose one of two ways, the hard way and the easy way.
1- The hard way:
The hard way is using your favorite text editor and the command prompt to compile your program.
Notepad is not bad choice, but do not forget two things:
1- To save the file you have created in plain text format.
2- To save the file as .mp4 (that’s to be easy to reopen it with MetaEditor), but you can save it as any extension you prefer.
After saving your program there is an extra step to make your code comes out to the light.
It’s the Compiling step.
Compiling means to convert the human readable script that you have just wrote to the machine language that your computer understands.
MetaTrader has been shipped with its own compiler (the program which will convert your script to the machine language) called MetaLang.exe.
Metalang.exe is a console program which takes two parameters and output an .ex4 file (the file which Metatrader understands).
The first parameter is “options” parameter and the only option available is –q quit
The second parameter is the full path to your .mql file.
The syntax will be in this format.
metalang [options…] filename
Example:
1- Find your metalang.exe path, it will be the same path of MetaTrader (here my path is D:\Program Files\MetaTrader 4).
2- Create a batch file and name it compile.bat (or any name you prefer).
3- Write these lines into the bat file then save it:
cd D:\Program Files\MetaTrader 4
metalang -q "D:\Program Files\MetaTrader 4\my_first_mql4_script.mq4"
(Don’t forget to change the path to you MetaTrader installed path).
4- Run the batch file and if you are lucky person like me you will get a screen like figure 1.
Figure 1 Metalang compiler
As you see you will get the output file “my_first_mql4_script.ex4”
2-The easy way:
Metatrader has been shipped with a good IDE (integrated development editor) called MetaEditor which has these features:
1- A text editor has the feature of highlighting different constructions of MQL4 language while you are writing/reading code.
2- Easy to compile your program, just click F5 and the MetaEditor will make all the hard work for you and produces the “ex4” file.
Besides it’s easy to see what the wrong in your program is (in the Error Tab – see figure 2).
3- Built-in a dictionary book which you can access by highlight the keyword you want to know further about it then press F1.

Figure 2 MetaEditor 4
In the coming lessons we will know more about MetaEditor.
Today I just came to say hello, tomorrow we will start the real works and will study the Syntax of MQL4.
I welcome very much the questions and the suggestions.
See you
Coders’ Guru