Errors 4066 and 4073 in strategy tester ( while history is available )

Back to topics list To post a new topic, please log in or register
avatar
79
burgie 2016.02.11 20:19
 

I have a class that I use to check for a new bar. I initiate a timer in OnInit with the iTime function.  Then in OnTick I check to see if the timer still corresponds with the time of the current bar.

Yesterday I noticed a weird behavior in the Strategy Tester (ST), which doesn’t happen in real trading (I think). After adding some information to the log I noticed that I get some errors about the history getting updated if I run the ST for the first time after starting the terminal. On the second run there doesn’t seem to be a problem.

This is part of the log you get when you run the code below for the first time:

0             19:57:20               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ OnInit

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ Error = 4066

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ Timer = 1451858400

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === OnTick 1

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Error = 4073

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Current = 0

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === OnTick 2

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Error = 0

0             19:57:22               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Current = 1451858400

When you start the ST for a second time (without closing the terminal) you get this:

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ OnInit

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ Error = 0

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: +++ Timer = 1451858400

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === OnTick 1

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Error = 0

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Current = 1451858400

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === OnTick 2

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Error = 0

0             19:57:24               2016.01.03 22:05  Clock test EURUSD.lmx,M1: === Current = 1451858400

Now why would the history not be up to date before the test is actually started? And if it’s not up to date then why does iTime return a valid value the first time it’s called, and then return a 0 on the second time? I’m on build 950 by the way.

class TimerClass
{

 public:
 int      TimerPeriod;
 datetime Timer;
 
 
 void Set( int RequestedPeriod )
 {
   TimerPeriod = RequestedPeriod;
   if( Timer == 0 ) Timer = iTime( Symbol() , TimerPeriod , 0 );
   Print( "+++ Error = " + GetLastError() );
   Print( "+++ Timer = " + Timer );
 }


 bool Event()
 {
    datetime Current = iTime( Symbol() , TimerPeriod , 0 );
    Print( "=== Error = " + GetLastError() );
    Print( "=== Current = " + Current );
    
    if( Timer != Current )
    {
       Timer = Current;
       return( true );
    }

    return( false );
 }

};



TimerClass   Clock;
int Times = 1;



int OnInit()
{

 Print( "+++ OnInit" );
 Clock.Set( PERIOD_H1 );
   
 return(0);
}



void OnTick()
{

 if( Times <= 2 )
 {
 
    Print( "=== OnTick " + Times );
    Clock.Event();
    Times++;
    
 }

}

avatar
79
burgie 2016.02.15 20:40 #
 
Seriously, has nobody ever noticed this?
avatar
2017
gooly 2016.02.15 21:59 #
 
Have you read what Error = 4066 means?

I wouldn't take it as an error but as an advice.

avatar
125
zirkoner 2016.02.15 22:16 #
 
burgie:
Seriously, has nobody ever noticed this?
Don't check for error when there is no error.
avatar
79
burgie 2016.02.19 16:32 #
 
4066 might not be an error but 4073 apparently is because iTime returned a zero.
Back to topics list  

To add comments, please log in or register