Previous Next

GZigZag.Ready()

Checks if the data of the class is ready for use.

After a class has been created and initialized, it needs a few ticks to collect all the data. This function checks if the data is ready for use.

This way, errors can be prevented when starting an expert based on the data from Glib.

bool  GZigZag.Ready();

Rückgabewert

If successful, true is returned and a message is displayed that the class data is ready.


Example:

//--- Include the Glib classes
#include <Glib.mqh>

//--- Creation of a pointer to an empty class object
GZigZag *zigZag;


int OnInit ()
{
   //--- Assign the class to the empty class object
   zigZag = gZigZag();

   //--- Initialize the data of the class
   zigZag.Init();

   return(INIT_SUCCEEDED);
}

void OnDeinit (const int reason)
{
   //--- Release memory on exit
   delete zigZag;
}


void OnTick ()
{
   if ( zigZag.Ready() ) //--- Prevents access to data that has not yet been prepared.
   {
      //--- Output the price of the last fixed extreme point directly:
      Print( zigZag.GetPrice(PERIOD_D1, 1) );
   }
}


See also

GZigZag