Strategy Tester anomaly - page 2

 

William 

I will take all that on board and have another look in the morning. 

Many thanks for that 

 

This seems to work OK - it's finding every new day now

(all my tick data is GMT-0, its only for testing so I'm good)

Thanks William 

#property copyright ""
#property link      ""
#property version   ""
#property strict

#property tester_everytick_calculate

#define ENABLE_TEST_INDICATORS false

bool     FirstEATick       = true   ;
bool     NewDay            = false  ;
string   DateCurrent       = ""     ; 

//*********************************************************************************
//*********************************************************************************

int OnInit()
   {
      int Num = 0 ;
      if ( Num != 0) 
      {
         return (INIT_PARAMETERS_INCORRECT) ;
      }
      TesterHideIndicators(!ENABLE_TEST_INDICATORS);
      return(INIT_SUCCEEDED);
   }

//**************************************************************************************
//**************************************************************************************

void OnDeinit(const int reason)
   {
//    Comment ("");
   }

//**************************************************************************************
//**************************************************************************************

void OnTick()    
   {

   if (FirstEATick) // Default = true
       {
         NewDay      = true ;
         DateCurrent = TimeToStr(TimeGMT(),TIME_DATE) ;
       }
   else
       {
         NewDay      = false ;
         string DateCheck = TimeToStr(TimeGMT(),TIME_DATE) ;
         if ( DateCheck != DateCurrent)
           {
             NewDay = true ;
             DateCurrent = TimeToStr(TimeGMT(),TIME_DATE) ;
           }   
       }



      if ( NewDay ) 
         {
            // Build Arrays 
            Print (TimeGMT());
         }


     FirstEATick  = false ;
     NewDay       = false ;
 
  }  
Reason: