DayOfYear

 

In the strategy tester, I run this:

if (DayOfYear()>=88) {StartHour=StartHour+1;EndHour=EndHour+1;}


However, it is always adding 1 hour even before March. Is it picking up the current server time? Do I have to use candle time instead? I can't see how I can backtest it any other way.

 
int TimeDayOfYear( datetime date)
 
SanMiguel:

In the strategy tester, I run this:

if (DayOfYear()>=88) {StartHour=StartHour+1;EndHour=EndHour+1;}


However, it is always adding 1 hour even before March. Is it picking up the current server time? Do I have to use candle time instead? I can't see how I can backtest it any other way.

Seems working fine when I tested. I suggest you use the code this way for example:

if (DayOfYear()>=88) {StartHour=10;EndHour=21;}


Use numbers because otherwise your StartHour and EndHour variables will be incremented on every tick.

Use Print(DayOfYear()); to view what is the day when you run the test.


 

Interesting point..

Documentation says

int DayOfYear( )

Returns the current day of the year (1 means 1 January,..,365(6) does 31 December), i.e., the day of year of the last known server time.
Note: At the testing, the last known server time is modelled.

..

as with

datetime TimeCurrent( )

Returns the last known server time (time of incoming of the latest quote) as number of seconds elapsed from 00:00 January 1, 1970.

Note: At the testing, the last known server time is modelled.

..

Are the docs wrong?

Rosh to comment?

-BB-

 
robofx.org:

Seems working fine when I tested. I suggest you use the code this way for example:

if (DayOfYear()>=88) {StartHour=10;EndHour=21;}


Use numbers because otherwise your StartHour and EndHour variables will be incremented on every tick.

Use Print(DayOfYear()); to view what is the day when you run the test.


Yes, it works correctly now but when I backtest to before March 29th, ie Jan, Feb, and March it still uses the current server time in the strategy tester.

Reason: