Previous Next


Used to prepare the data of GZigZag.

The call must take place before the first call of a data-reading function.

void  GZigZag.Init(
   string   symbol = NULL,                              // Symbol
   string   ExtPeriodes = "MN1,W1,D1,H4,H1,M15,M5,M1",  // Time frame in shorthand
   int      ExtBarHistory = 700,                        // Number of bars to process
   string   ExtAdditionalValues = "Volumes,RSI,MFI",    // Indicator values to the extreme points
   bool     IntelligentIndicators = true,               // More natural return values of the indicators
   int      ExtDepth = 12,                              // Minimum range between the same extreme points
   int      ExtDevitation = 5,                          // Percentage to reverse extreme points
   int      ExtBackstep = 3                             // Minimum distance between extreme points



[in]  The symbol whose data the class should process.


[in]  The time frames on which the class should process the data. These are specified in short form and separated by a comma without spaces. "H1,W1" therefore corresponds to PERIOD_H1 and PERIOD_W1 or 1 hour and 1 week.


[in]  Number of bars to be processed. The more bars, the higher the ZigZag shift that can be read out. To save the processor, a lower value should be selected if possible. But to avoid errors use a higher value.


[in]  Additional data that you want to read out to the extreme points. These indicators are automatically created and assigned to the extreme points when entering in the Init() function. Currently possible additional information are Volumes, RSI and MFI. If no additional data is required, it is recommended to set the value to "" empty.


[in]  If set to false the indicator value is evaluated directly at the extreme point. If set to true the sensible indicator extreme point is determined for the extreme points. This then leads to more natural, visually similar values.


[in]  The minimum range in bars between two top- or bottom- extreme points that should be recognized as movement.


[in]  The percentage value for the reversal of an extreme point at which a Zig becomes a Zag again and vice versa.


[in]  The minimum range in bars between two extreme points which should be recognized as movement.


The .Init() function call can be made at any point in the code. It can also be used multiple times to change data during runtime. However, it is recommended to call it at least once in the OnInit() and check the data with .Ready() for completeness.


//--- Include 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 class data


void OnDeinit (const int reason)
   //--- Release memory on exit
   delete zigzag;

See also