MQL4 Tutorial 8 – How to create your first Expert Advisor with MQL4 in 3 minutes


Okay now we know how we can import an expert advisor, but how can we create one?
Well this is very easy. We will just do the very simple hello world example in MQL4. So click this little icon here or hit the F4 key to bring up the MetaEditor and now you should see a screen looking like this one. Please click on new → expert advisor from template and we will name it bootcamp. My name is Raimund Bauer and my website is and I will click on next.
While the MetaEditor Menu is in English, the buttons are in German. So this one will be the next button, continue. And here we go.
The MetaEditor has automatically created a program with thirtyseven lines but we only need the Void OnTick part because this is the function that will be called each time when the price changes so cut out everything above this line and hit the delete key.
See this bracket? Here we will stop with the OnTick function and here is the end of the function. I will remove the Comments and move up the closing bracket and now we will type Comment and while you type the auto complete function will suggest the Comment function so I will select that and hit the F1 key. That will bring up the MetaTrader help and the help tells us the function outputs for Comment in the top left corner of a chart. So we use a round bracket and a string that is called Hello world and at the end we will tell the compiler with a semicolon that we are finished with the line.
Afterwards we have to compile the Expert Advisor. That means we are going to translate the text that is readable for humans into text that is readable for MetaTrader 4 and we’ll now create an MQL 4 and then EX4 file for the bootcamp EA so we will switch back to the trading terminal by hitting this little button or pressing F4.
And here it is: Our first written EA, and when we drag it on the chart you will see that it printed “hello world” in the left upper corner. That was very easy wasn’t it?