NavigationUser loginWho's new
Who's onlineThere are currently 0 users and 49 guests online.
|
Welcome to MQL4 course!Welcome to the MQL4 course. 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. The language enables you to create one of the following: 1- Expert Advisors. • 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? 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. 1- To save the file you have created in plain text format. After saving your program there is an extra step to make your code comes out to the light. 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 syntax will be in this format. 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: 4- Run the batch file and if you are lucky person like me you will get a screen like figure 1.
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. 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 |