Day of week

To add comments, please log in or register
I
353
I  

This is my first encounter with this function.

Comment("DayOfWeek() ", DayOfWeek());

When I run on strategy tester it shows me always number 5, no matter what day.

Can somebody please help?

Thank you.

Ray
2650
Ray  

Some commands just don't work or don't work as you think they should in the tester.

Try using a different command, maybe TimeDayOfWeek()

I
353
I  
phy:

Some commands just don't work or don't work as you think they should in the tester.

Try using a different command, maybe TimeDayOfWeek()


Sure. You are right. Thank you for the help.
burgie
217
burgie  

Someone else pointed to this thread as a warning. However DayOfWeek seems to perform as expected in the strategy tester. The problem probably lies in the usage of the comment function and not the dayofweek function.

Set the tester to daily and run the code below for a periode of a week. You will then see the different day numbers in your log.

Also take a look at this thread: https://www.mql5.com/en/forum/136118

int start()
{

 if( NewBar() )
 {
 
   Print( "Day of week = " + DayOfWeek() );
 
 }
 
}

bool NewBar()
{
  static datetime TimeCurrentBar;
  if ( TimeCurrentBar == Time[0] ) return( false );
  else
  {
    TimeCurrentBar = Time[0];
    return( true );
  }  
}
To add comments, please log in or register