Previous Next

GTrade.ChartEvent()

Contains the functions for triggering ChartEvents in relation to Glib functions.

It is recommended to integrate this function in every expert, in every Glib class.

void  GTrade.ChartEvent(
   const int     id,       // id to be passed on
   const long    &lparam,  // long parameter to be passed on
   const double  &dparam,  // double parameter to be passed on
   const string  &sparam   // string parameter for passing on
   );

Parameters

id

[in]  id to pass to the Glib ChartEvent. Here simply enter the variables from OnChartEvent.

lparam

[in]  long Parameter for passing to the Glib ChartEvent. Here simply enter the variables from OnChartEvent.

dparam

[in]  double Parameter to pass on to the Glib ChartEvent. Just enter the variables from OnChartEvent here.

sparam

[in]  string Parameter to pass on to the Glib ChartEvent. Just enter the variables from OnChartEvent here.

Note

This function should be used always when using the class, as it provides the trade functions of the class among other things.


Example:

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

//--- Create a pointer to an empty class object
GTrade *trade;


int OnInit ()
{
   //--- Assign the class to an empty class object
   trade = gTrade();

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

   //--- Add a trade button
   trade.AddButton("Trade");

   return(INIT_SUCCEEDED);
}

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

void OnTick ()
{
   //--- Show CRV automatically for existing lines
   trade.CalculateCRV();
}


void OnChartEvent (const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
      //--- Use ChartEvents of the class
      trade.ChartEvent(id, lparam, dparam, sparam);
}


See also

GTrade.Init, GTrade.AddButton