Skeleton of the code

Download PDF

Once you are done setting all the necessary parameters, click the Finished button and the MetaQuotes Editor will create the skeleton of the code for you as shown in the next figure.

  • The first five lines (lines 1 through 5) represent comments containing the name of the EA (file name), the name of the manufacturing company and its website. You can write here anything you like. This text will not be seen anywhere and can even be skipped. The information it contains only targets the developer;
  • The next 3 lines (lines 6 through 8) represent the Parameter Block. This information can be observed when starting the EA in the terminal. Parameter Block contains information for the terminal allowing it to handle the EA in a proper way. The most common parameters are the EA version, name of manufacturing company and a brief description.
  • It is followed by the OnInit() function This is the OnInit() Block. OnInit() Block gains control once the EA is loaded into the terminal. It can contain various data related to the initialization of the EA - declaring variables and arrays, getting indicator handles, etc. That is, this block does not have any functions that would be directly associated with trading.
  • The OnDeinit(const int reason) function goes next. It has one parameter that specifies the reason for EA shutdown.If the EA initialization is unsuccessful, this function receives a relevant code as a parameter;
  • The last function is OnTick(). This block can be said to be the "brains" of the EA as it comprises all functions in charge of trades.