unable to set global variables of TesterStats within OnTester()

 

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);
}
 
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). 

Reason: