Previous Next

GZigZag.GetAllLineLengths()

Fills a double array with the price differences between the extreme points.

void  GZigZag.GetAllLineLengths(
   ENUM_TIMEFRAMES  timeFrame,           // Timeframe of the desired value
   double           &array[]             // Array for outputting the data
   int              start = 0            // From which element the copying should start
   int              count = WHOLE_ARRAY  // Maximum number of data to be output
   );

Parameter

timeFrame

[in]  Time frame of the extremum

&array[]

[out]  The array to be filled with data.

start

[in]  Number of the extremum point at which the copying should start. The current unfinished extremum point is at position 0 (zero).

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 or enlarged 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 passed from the terminal to Glib, there may be occasional errors in the output.


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)
{
   //--- Release memory on exit
   delete zigZag;
}


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

      //--- Fill array
      zigZag.GetAllLineLengths(PERIOD_M15, array);

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


See also

GZigZag, GZigZag.Get, GZigZag.GetAll, GZigZag.GetPrice, GZigZag.GetAllPrices