Previous Next

GZigZag.Get()

Returns a GStructZigZag object of a specific completed formation.

GStructZigZag  GZigZag.Get(
   ENUM_TIMEFRAMES  timeFrame,   // Timeframe of the desired formation
   int              ZigZagShift  // Position of the extremum
   );

Parameter

shift

[in]  Position of the extremum point (not the bar shift). 0 means the current unfinished extremum point.

timeFrame

[in]  Timeframe of the extremum point.

Return value

In case of success, a GStructZigZag object is returned. In case of error, all parameters in the returned object are 0 (zero).


Example:

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

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


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

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

   return(INIT_SUCCEEDED);
}

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


void OnTick ()
{
   if ( zigZag.Ready() ) //--- Will be executed only when all data are ready
   {
      //--- Save the last extreme point and output the volume:
      GStructZigZag tempZigZag = zigZag.Get(PERIOD_D1, 0);
      Print( tempZigZag.Volume );

      //--- Output the date of the last finished extreme point:
      Print( zigZag.Get(PERIOD_D1, 1).date );
   }
}


See also

GZigZag, GZigZag.GetAll, GZigZag.GetAllLineLenghts, GZigZag.GetPrice, GZigZag.GetAllPrices