How To Remove 1.#J from Strategy Tester Optimization Results

 

Hi there !

Does any know how to remove the 1.#J symbol when Profit Factor is NULL running Custom Max Optimization Type.

I have placed my OnTester() code below but it is not working at all and picture is attached.

double OnTester()
  {
   double param=0;

   double pSTAT_PROFIT=TesterStatistics(STAT_PROFIT);
   double pSTAT_PROFIT_FACTOR=TesterStatistics(STAT_PROFIT_FACTOR);
   double pSTAT_RECOVERY_FACTOR=TesterStatistics(STAT_RECOVERY_FACTOR);
   double pSTAT_EQUITYDD_PERCENT=TesterStatistics(STAT_EQUITYDD_PERCENT);
   double pSTAT_TRADES=TesterStatistics(STAT_TRADES);

   if(pSTAT_TRADES>10)
      param=pSTAT_PROFIT*pSTAT_PROFIT_FACTOR;
   else
      param=-1;

   if(pSTAT_PROFIT<=0) param=param/100;

   if(pSTAT_PROFIT_FACTOR<=2) param=param/100;
   if(pSTAT_RECOVERY_FACTOR<=2) param=param/100;

   if(pSTAT_EQUITYDD_PERCENT<=0) param=param/100;
   if(pSTAT_EQUITYDD_PERCENT>=10) param=param/100;

   return(param);
  }

Thank you

Marcelo 

Files:
Capturar.PNG  44 kb
 
I'm interested to know.
 

As kindly informed by Malacarne, here is the answer.

   if (pSTAT_PROFIT_FACTOR==EMPTY_VALUE) param=-1;