Filter trading days coding

 

I am coding testing an EA idea

Which code do I add so the EA does not open new trades on Friday


Much appreciated

 
Don Calito:

I am coding testing an EA idea

Which code do I add so the EA does not open new trades on Friday


Much appreciated

  if(DayOfWeek()==5) return(0);

ref: https://docs.mql4.com/dateandtime/dayofweek

DayOfWeek - Date and Time - MQL4 Reference
DayOfWeek - Date and Time - MQL4 Reference
  • docs.mql4.com
DayOfWeek - Date and Time - MQL4 Reference
 
Or you can create a bit mask and be able to use the optimizer.
input uint dowEnabled=127; // 127 all=[Sunday … Saturday]
bool is_dow_allowed(){ return 1<<DayOfWeek() & dowEnabled != 0); }