Previous Next

GTrade.AddButton()

Adds another trade button to the chart.

void  GTrade.AddButton(
   string     buttonText = "",                   // Display name
   GTradeRisks  RiskMode = RISK_PERCENT            // Risk selection RISK_PERCENT or RISK_FIXED
   double     RiskPercent = 2,                   // Risk specification with RISK_PERCENT
   double     RiskFixed = 50,                    // Specification of risk at RISK_FIXED
   double     autoTakeProfitCRV = 0,             // Automatic TakeProfit at CRV
   color      backgroundColor = clrForestGreen,  // Background color
   color      textColor = clrWhite,              // Text color
   int        FontSize = 20                      // Text size
   );

Parameter

buttonText

[in]  The text that should be on the button.

RiskMode

[in]  The mode by which the risk is to be calculated. Percent or a fixed value of the money. See also GTradeRisks

RiskPercent

[in]  Risk in percent if RiskMode = RISK_PERCENT.

RiskFixed

[in]  Risk in money if RiskMode = RISK_FIXED.

autoTakeProfitCRV

[in]  Automatically sets a TakeProfit to the desired CRV value.

backgroundColor

[in]  The background color of the button.

textColor

[in]  The font color of the button.

FontSize

[in]  The font size of the button.


Note

Further calls of this function generate further buttons. As long as you have space in the vertical of your chart you can place unlimited buttons with different values.


Example:

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

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


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

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

   //--- Add a trade button with 5 percent risk
   trade.AddButton("Trade", RISK_PERCENT, 5);

   return(INIT_SUCCEEDED);
}

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


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.ChartEvent