Previous Next

GTrade.CalculateCRV()

Calculates and draws the current Chance-Risk-Value on the chart.

void  GTrade.CalculateCRV();

Note

This function requires lines with the names "StopLoss", "TakeProfit" and optionally "Pending" to perform the calculations. These are automatically found when using the function GTrade.ChartEvent()


Example:

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

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


int OnInit ()
{
   //--- Assign the class to the 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)
{
   //--- Free up memory on exit
   delete trade;
}

void OnTick ()
{
   //--- For existing lines, display CRV automatically
   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.CalculateCRV