Previous Next

GZigZag.GetAll()

Fills a GStructZigZag object array with the extreme point values.

void  GZigZag.GetAll(
   ENUM_TIMEFRAMES  timeFrame,           // Timeframe of the desired value
   GStructZigZag    &array[]             // Array for output of the data
   int              count = WHOLE_ARRAY  // Maximum number of data to be output
   );

Parameter

timeFrame

[in]  Timeframe of the extremum

&array[]

[out]  The array to be filled with data. Due to a bug in the MT5 terminal, before the array is passed to the function, it must be reserved with ArrayResize() enough memory.

count

[in]  Number of elements to be read.

Return value

In case of success, the passed array is filled with the elements and the array is shortened to the number of elements. In case of error, the size of the array is 0 (zero) and a message is output.

Note

The array should always be checked for content after filling. Due to incomplete historical data transferred from the terminal to Glib, there may be occasional errors in the output.


Beispiel:

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

//--- Erzeugung eines Zeigers zu einem leeren Klassenobjektes
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)
{
   //--- Release memory on exit
   delete zigZag;
}


void OnTick ()
{
   if ( zigZag.Ready() ) //--- Will only be executed when all data is ready
   {
      //--- Create structure array
      GStructZigZag array[];

      //--- Allocate memory
      ArrayResize(array, 256);

      //--- Fill the array
      zigZag.GetAll(PERIOD_H1, array);

      //--- Check and output the penultimate fixed value
      if (ArraySize(array)  >= 3)
      {
         Print(array[2].date);
      }
   }
}


See also

GZigZag, GZigZag.Get, GZigZag.GetAllLineLenghts, GZigZag.GetPrice, GZigZag.GetAllPrices