OnTester Result different than the displayed on the Optimization Results

I am using Custom max optimization mode.

I have the following list:

Running single test (using right click on the above) I get the following in the Journal:
OnTester result 16.70300875033711

The difference is quite big. And 16 is the correct number.

After some investigation I have found the for some reason TimeCurrent() is returning wrong value in OnTester() because of missing real ticks or something.

Anyone else having similar issues?

What wrong value ? Can you provide information to reproduce this issue ?

My testing period is 01.09.2014 to 28.01.2017.

Everything is going fine but when finishing the test and running the OnTesterMethod TimeCurrent is returning 02.09.2014 for some reason. I guess the reason is the missing data for “real ticks”

Here is the output in the Journal:

....
.....
.....
2017.02.02 11:53:43.244 2017.01.17 09:33:14   order performed sell 0.01 at 1.00367 [#287 sell 0.01 USDCHFeur at 1.00368]
2017.02.02 11:54:00.871 old tick EURCHFeur 2014.09.01 05:56:00 (2017.01.27 21:54:57)
2017.02.02 11:54:00.872 old tick EURCHFeur 2014.09.01 05:59:30 (2017.01.27 21:54:57)
2017.02.02 11:54:00.872 old tick EURCHFeur 2014.09.01 06:00:10 (2017.01.27 21:54:57)
2017.02.02 11:54:00.873 old tick EURCHFeur 2014.09.01 06:00:46 (2017.01.27 21:54:57)
2017.02.02 11:54:00.874 old tick EURCHFeur 2014.09.01 06:01:50 (2017.01.27 21:54:57)
2017.02.02 11:54:00.874 old tick EURCHFeur 2014.09.01 06:03:24 (2017.01.27 21:54:57)
2017.02.02 11:54:00.875 old tick EURCHFeur 2014.09.01 06:05:23 (2017.01.27 21:54:57)
2017.02.02 11:54:00.875 old tick EURCHFeur 2014.09.01 06:07:49 (2017.01.27 21:54:57)
2017.02.02 11:54:00.876 old tick EURCHFeur 2014.09.01 06:09:58 (2017.01.27 21:54:57)
2017.02.02 11:54:01.090 old tick EURCHFeur 2014.09.01 22:18:50 (2017.01.27 21:54:57)
2017.02.02 11:54:01.091 old tick EURCHFeur 2014.09.01 22:22:58 (2017.01.27 21:54:57)
2017.02.02 11:54:01.091 old tick EURCHFeur 2014.09.01 22:24:16 (2017.01.27 21:54:57)
2017.02.02 11:54:01.092 old tick EURCHFeur 2014.09.01 22:28:24 (2017.01.27 21:54:57)
2017.02.02 11:54:01.093 old tick EURCHFeur 2014.09.01 22:37:42 (2017.01.27 21:54:57)
2017.02.02 11:54:01.093 old tick EURCHFeur 2014.09.01 22:38:15 (2017.01.27 21:54:57)
2017.02.02 11:54:01.094 old tick EURCHFeur 2014.09.01 22:39:31 (2017.01.27 21:54:57)
2017.02.02 11:54:01.095 old tick EURCHFeur 2014.09.01 22:44:32 (2017.01.27 21:54:57)
2017.02.02 11:54:01.095 old tick EURCHFeur 2014.09.01 22:45:52 (2017.01.27 21:54:57)
2017.02.02 11:54:01.296 old tick EURCHFeur 2014.09.02 08:43:09 (2017.01.27 21:54:57)
2017.02.02 11:54:01.297 old tick EURCHFeur 2014.09.02 08:43:20 (2017.01.27 21:54:57)
2017.02.02 11:54:01.297 old tick EURCHFeur 2014.09.02 08:43:31 (2017.01.27 21:54:57)
2017.02.02 11:54:01.298 old tick EURCHFeur 2014.09.02 08:44:01 (2017.01.27 21:54:57)
2017.02.02 11:54:01.299 old tick EURCHFeur 2014.09.02 08:44:31 (2017.01.27 21:54:57)
2017.02.02 11:54:01.299 old tick EURCHFeur 2014.09.02 08:45:26 (2017.01.27 21:54:57)
2017.02.02 11:54:01.300 old tick EURCHFeur 2014.09.02 08:45:54 (2017.01.27 21:54:57)
2017.02.02 11:54:01.300 old tick EURCHFeur 2014.09.02 08:46:42 (2017.01.27 21:54:57)
2017.02.02 11:54:01.301 old tick EURCHFeur 2014.09.02 08:47:44 (2017.01.27 21:54:57)
2017.02.02 11:54:01.519 old tick EURCHFeur 2014.09.02 16:12:00 (2017.01.27 21:54:57)
2017.02.02 11:54:01.519 old tick EURCHFeur 2014.09.02 16:13:02 (2017.01.27 21:54:57)
2017.02.02 11:54:01.520 old tick EURCHFeur 2014.09.02 16:15:16 (2017.01.27 21:54:57)
2017.02.02 11:54:01.521 old tick EURCHFeur 2014.09.02 16:15:52 (2017.01.27 21:54:57)
2017.02.02 11:54:01.521 old tick EURCHFeur 2014.09.02 16:16:36 (2017.01.27 21:54:57)
2017.02.02 11:54:01.522 old tick EURCHFeur 2014.09.02 16:20:25 (2017.01.27 21:54:57)
2017.02.02 11:54:01.522 old tick EURCHFeur 2014.09.02 16:24:06 (2017.01.27 21:54:57)
2017.02.02 11:54:01.523 old tick EURCHFeur 2014.09.02 16:25:17 (2017.01.27 21:54:57)
2017.02.02 11:54:01.523 old tick EURCHFeur 2014.09.02 16:25:57 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:32 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:32 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:34 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:35 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:35 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:35 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:41 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:41 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:45 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:45 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:46 (2017.01.27 21:54:57)
2017.02.02 11:54:01.606 old tick EURCHFeur 2014.09.02 23:47:46 (2017.01.27 21:54:57)
....
....
2017.02.02 11:54:01.608 old tick EURCHFeur 2014.09.02 23:59:52 (2017.01.27 21:54:57)
2017.02.02 11:54:01.608 old tick EURCHFeur 2014.09.02 23:59:57 (2017.01.27 21:54:57)
2017.02.02 11:54:01.608 old tick EURCHFeur 2014.09.02 23:59:57 (2017.01.27 21:54:57)
2017.02.02 11:54:01.608 old tick EURCHFeur 2014.09.02 23:59:58 (2017.01.27 21:54:57)
2017.02.02 11:54:01.608 2014.09.02 23:59:58   dd:2.224870878029398
2017.02.02 11:54:01.608 2014.09.02 23:59:58   timeCurrent:2014.09.02 23:59:58
2017.02.02 11:54:01.608 2014.09.02 23:59:58   testEndDate:2017.01.28 00:00:00
2017.02.02 11:54:01.608 2014.09.02 23:59:58   testStartDate:2014.09.01 00:00:00
2017.02.02 11:54:01.608 2014.09.02 23:59:58   timeDiference:172798.0
2017.02.02 11:54:01.608 2014.09.02 23:59:58   testTotalTime:76032000.0
2017.02.02 11:54:01.608 2014.09.02 23:59:58   profit:54.15000000000001
2017.02.02 11:54:01.608 2014.09.02 23:59:58   ret=coefficient*100;0.2272700968013468
2017.02.02 11:54:01.608 final balance 1054.15 EUR
2017.02.02 11:54:01.608 OnTester result 0.2272700968013468

Your test seems to finish on 2014.09.02 ?

Anyway, difficult to follow a log without the code that produced it.

Here is the code:

double OnTester()
  {
   double ret=0;

   if(TesterStatistics(STAT_TRADES)==0)
     {
      ret=0.0;
     }
   else
     {
      PrintC("STAT_BALANCEDD_PERCENT"+TesterStatistics(STAT_BALANCEDD_PERCENT));
      PrintC("STAT_BALANCE_DDREL_PERCENT"+TesterStatistics(STAT_BALANCE_DDREL_PERCENT));
      PrintC("STAT_EQUITY_DDREL_PERCENT"+TesterStatistics(STAT_EQUITY_DDREL_PERCENT));
      PrintC("STAT_EQUITY_DD_PERCENT"+TesterStatistics(STAT_EQUITYDD_PERCENT));
      double profit=TesterStatistics(STAT_PROFIT);

      double dd=TesterStatistics(STAT_EQUITYDD_PERCENT);
      //calculate how far we are from the end date
      datetime timeCurrent;
      timeCurrent=TimeCurrent();
      double timeDifference=timeCurrent-testStartDate;
      double testTotalTime=testEndDate-testStartDate;
      PrintC("profit:"+profit);
      double coefficient=timeDifference/testTotalTime;
      PrintC("dd:"+dd);
      PrintC("coefficient:"+coefficient);
      PrintC("timeCurrent:"+timeCurrent);
      PrintC("testEndDate:"+testEndDate);
      PrintC("testStartDate:"+testStartDate);
      PrintC("timeDiference:"+timeDifference);
      PrintC("testTotalTime:"+testTotalTime);
      PrintC("profit:"+profit);
      if(profit>0)
        {
         if(coefficient<0.91)
           {
            ret=coefficient*100;
            PrintC("ret=coefficient*100;"+ret);
            PrintC("ret"+ret);
            return(ret);
           }
         else
           {
            ret=profit*coefficient/dd;
            PrintC("ret=profit*coefficient/dd;"+ret);
            return(ret);
           }
        }
      else
        {
         PrintC("ret=profit;"+ret);
        }

     }
   PrintC("return ret");
   return ret;
  }
As I researched this further TimeCurrent() returns 02.09.2014 because there are missing real ticks for (2017.01.27 21:54:57)

I will try to get around this somehow.