GTrade.CalculateCRV()
Returns the chance-risk ratio of the entered prices.
double GTrade.CalculateCRV(
double stopLoss,
double takeProfit,
double pending = 0
);
|
Parameter
stopLoss
[in] The price of the StopLoss.
takeProfit
[in] The price of the TakeProfit.
pending
[in] The price of the pending order.
Return value
Example:
//--- Include Glib classes
#include <Glib.mqh>
//--- Creating a pointer to an empty class object
GTrade *trade;
GChartPatterns *chartPatterns;
int OnInit
()
{
//--- Assign the class to the empty class object
trade = gTrade();
chartPatterns = gChartPatterns();
//--- Initialize the class data
trade.Init();
chartPatterns.Init();
return(INIT_SUCCEEDED);
}
void OnDeinit
(const int reason)
{
//--- Free memory on exit
delete trade;
delete chartPatterns;
}
void OnTick
()
{
if
( chartPatterns.Ready() ) //--- Will only be executed when all data is ready
{
//--- Create structure array
GStructChartPatterns patternInfo;
//--- Waits for a breakout signal
if
(chartPatterns.Signal(patternInfo))
{
//--- If the direction of the formation is Long
//--- and CRV over 2.6:1,
if
( patternInfo.targetDirection == DIRECTION_LONG && trade.CalculateCRV(patternInfo.middle, patternInfo.highest) >= 2.6 )
{
//--- then open a trade with StopLoss at the center of the formation
trade.Open(patternInfo.middle);
}
}
}
}
|
See also
GTrade.CalculateCRV