Posted By:
30 Jul, 2014 10:11 am PDT

Implementation in MetaTrader

Please give an example of implementation of a code in MetaTrader.

As a rule, function descriptions are indicated in the same sequence as they are called for execution by the client terminal. Namely, first goes the description of init(), then start(), and the last one is deinit(). However, special functions are called for execution by the client terminal in accordance with their own properties. That is why the location of a description in a program does not matter.

Attachment:None


Example of implementation

 

//--------------------------------------------------------------------

// possible.mq4

// To be used as an example in MQL4 book.

//--------------------------------------------------------------------

int Count=0;                                    // Global variable

//--------------------------------------------------------------------

int start()                                     // Special funct. start()

   {

   double Price = Bid;                          // Local variable

   Count++;

   Alert("New tick ",Count,"   Price = ",Price);// Alert

   return;                                      // exit start()

   }

//--------------------------------------------------------------------

int init()                                      // Special funct. init()

   {

   Alert ("Function init() triggered at start");// Alert

   return;                                      // Exit init()

   }

//--------------------------------------------------------------------

int deinit()                                    // Special funct. deinit()

   {

   Alert ("Function deinit() triggered at exit");// Alert

   return;                                      // Exit deinit()

   }

Starting this EA, you will see that the execution sequence of special functions in a program does not depend on the order of descriptions in a program.

Was it useful?  




Please login to reply to this problem.