“Like sands through the hourglass, so are the days of our trades.”
Heavy-handed 80’s soap opera references aside, trading days can matter! For the longest time I relied on a clunky mechanism for selecting which days to trade:
if(DayOfWeek() >= start_day && DayOfWeek() <= end_day)
Simple enough, right? If I want to start trading on day 1 (Monday) and stop trading on day 3 (Wednesday) that works out swimmingly! What if I want to start trading on Wednesday and stop on Monday? Uh oh…
For a more elegant approach to selecting trading days, try this instead!
Add these variables to your other global external variables:
input bool Sunday=1; // Trade on Sunday
input bool Monday=1; // Trade on Monday
input bool Tuesday=1; // Trade on Tuesday
input bool Wednesday=1; // Trade on Wednesday
input bool Thursday=1; // Trade on Thursday
input bool Friday=1; // Trade on Friday
Then you can use those conditions for deciding which days to enter trades:
if((DayOfWeek()==0 && Sunday==1)
|| (DayOfWeek()==1 && Monday==1)
|| (DayOfWeek()==2 && Tuesday==1)
|| (DayOfWeek()==3 && Wednesday==1)
|| (DayOfWeek()==4 && Thursday==1)
|| (DayOfWeek()==5 && Friday==1))
{
analyze();
}
The EA input selections should look like this. Cheers, and let me know if you have any questions!