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?
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()
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
if( NewBar() )
Print( "Day of week = " + DayOfWeek() );
static datetime TimeCurrentBar;
if ( TimeCurrentBar == Time ) return( false );
TimeCurrentBar = Time;
return( true );