Download MetaTrader 5
To add comments, please log in or register
Take active part in the life of the community. Improve your rating!
Bill Doerrfeld
273
Bill Doerrfeld 2016.08.11 16:25 

Trying to get gvs of testerstats and the following is not working. Have also tried placing the code within Start() within an IsTesting() condition and still no go.

How do I retrieve TesterStatistics? 

//*************************************************************** 1 **
// INITIALIZATION
//********************************************************************                                  

int OnInit()
{
   GlobalVariablesDeleteAll();
   Print("Deleted all global variables");
   return(INIT_SUCCEEDED);
}


void OnTester()
{
GlobalVariableSet("PL",TesterStatistics(STAT_PROFIT));
GlobalVariableSet("NumTrades",TesterStatistics(STAT_TRADES));
GlobalVariableSet("PF",TesterStatistics(STAT_PROFIT_FACTOR));
//double Win = TesterStatistics(STAT_PROFIT_TRADES / NumTrades);
//Win = NormalizeDouble(Win,2);
GlobalVariableSet("DD",TesterStatistics(STAT_BALANCE_DDREL_PERCENT));
}


//*************************************************************** 2 **
// DEINITIALIZATION
//********************************************************************                                  

void OnDeinit(const int reason)
{
   Print(reason);
}
Bill Doerrfeld
273
Bill Doerrfeld 2016.08.11 17:12  
billworld:

Trying to get gvs of testerstats and the following is not working. Have also tried placing the code within Start() within an IsTesting() condition and still no go.

How do I retrieve TesterStatistics? 

 

Nevermind, I'm getting what I want with the following:

double OnTester()
{
double PL = TesterStatistics(STAT_PROFIT);
   PL = NormalizeDouble(PL,2);
double PF = TesterStatistics(STAT_PROFIT_FACTOR);
   PF = NormalizeDouble(PF,2);
double NumTrades = TesterStatistics(STAT_TRADES);
double PT = TesterStatistics(STAT_PROFIT_TRADES);
double Win = 0;
   if(PT > 0) Win = PT / NumTrades;
   Win = NormalizeDouble(Win,2);
double DD = TesterStatistics(STAT_BALANCEDD_PERCENT);
   DD = NormalizeDouble(DD,2);
   
GlobalVariableSet("PL",PL);
GlobalVariableSet("PF",PF);
GlobalVariableSet("NumTrades",NumTrades);
GlobalVariableSet("Win",Win);
GlobalVariableSet("DD",DD); 

return(1);
}

 

Would be helpful to retrieve other stats such as TestStartDate, TestEndDate, Win%, Spread, TotalLots and CommissionCosts (which would of course require a CommissionCost input param be added). 

/
To add comments, please log in or register