Previous Next

GChartPatterns

The class GChartPatterns shows past and upcoming course formations.

All formations from the selected time units are considered.

Simply create the class and the data is automatically determined. The values can then be read out and used with simple functions.


Creating and Destroying the Class

To create the class and destroy it when the program ends, there are 5 simple steps necessary. You can find these steps in the example.

Example:

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

//--- Creation of a pointer to an empty class object
GChartPatterns *chartPatterns;


int OnInit ()
{
   //--- Assign the class to the empty class object
   chartPatterns = gChartPatterns();

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

   return(init_succeeded);
}

void OnDeinit (const int reason)
{
   //--- Free the memory when ending
   delete chartPatterns;
}

From this point on you can use the class functions.

Due to the amount of data Glib produces, a few ticks are required when starting until all data has been recorded.

To check if all data has been prepared and to avoid errors when starting, it is recommended to check the class function .Ready() on true.

Example:

void OnTick ()
{
   if ( chartPatterns.Ready() ) //--- Will only be executed when all data is ready
   {
      //--- Draws all selected formations on the chart.
      chartPatterns.JustPaint();
   }
}


Functions of the class

Return value

Function call

Function

Deinit()

Pre-destructor of the class. To remove the class data carefully.

void

Init()

Initialization of the class default data. Specify which default values the class should work with.

bool

Signal()

Returns a signal and information as GStructChartPatterns when a formation reaches a certain point.

GStructChartPatterns

GetFinish()

Writes all information of a finished/confirmed formation into a GStructChartPatterns object.

void

GetAllFinish()

Writes all information about all finished/confirmed formations of a time unit in a GStructChartPatterns object array.

void

GetBuild()

Writes all information about all upcoming formations of a time unit in a GStructChartPatterns object array.

GStructChartPatterns

GetBuild()

Returns all information about a specific formation that occurs in a specific time unit as GStructChartPatterns.

void

SetPaintBuild()

Sets if patterns in build are drawn.

void

SetPaintFinish()

Sets if finished chart patterns are drawn.

void

JustPaint()

If no other function calls are done, this function can be used to start the drawing of the formations.

void

ClearPaint()

Removes all drawings of the class from the chart.

bool

Ready()

Checks if the class is ready for use.

void

ChartEvent()

Sets the chart events to enable the removal of the class and increase the visibility in the chart.


Structures of the class

struct  GStructChartPatterns
{

   ENUM_TIMEFRAMES                   timeFrame;           // Timeframe of the formation
   string                            name;                // string Name of the formation
   GEnumChartPatternsIdentification  identification;      // Formationsidentifikation
   GDirections                       targetDirection;     // Planned breakout direction
   GEnumChartPatternsStates          state;               // formation status
   int                               completeness;        // Completeness in percent
   double                            probability;         // Current probability of an eruption
   double                            maxProbability;      // Maximum probability of an outbreak
   double                            defaultProbability;  // Standard probability of a breakout

   GStructChartPatternsLines  topLine;            // Upper breakout line
   GStructChartPatternsLines  bottomLine;         // Lower breakout line
   double                     breakoutPointLong;  // Current long breakout point
   double                     breakoutPointShort// Current short breakout point
   datetime                   begin;              // Formation start date
   datetime                   end;                // Current end date of the formation
   int                        beginShift;         // Bar shift of the formation start date
   int                        endShift;           // Bar shift of the formation end date

   double                     highest;  // Highest price of the formation
   double                     lowest;   // Lowest price of the formation
   double                     middle;   // Middle price of the formation
   };



struct  GStructChartPatternsLines
{

   double    priceBegin;  // Price of the beginning of the line
   datetime  dateBegin;   // Date of the beginning of the line
   int       shiftBegin;  // Bar shift of the beginning date

   double    priceEnd;    // Endprice of the line
   datetime  dateEnd;     // Enddate of the line
   int       shiftEnd;    // Bar shift of the end date
   };

Enumerations of the class

GEnumChartPatternsStates

Identifier

Description

CP_NONE

No formation recognized.

CP_CONSTRUCTIVE

Potential pattern in build.

CP_EARLYBIRD

Last planned reversal point before the breakout. Order placement possibility for early birds.

CP_BREAKOUT

Breakout point from the formation.

CP_FINISHED

After the breakout, the formation has travelled a certain distance, which qualifies it as confirmed.