I was thinking to have some 'fun' with this!
//+------------------------------------------------------------------+ //| TimeFilter.mq4 | //+------------------------------------------------------------------+ extern string line1="Enter days to trade" ; extern string tradingdays="Mon,Tue,Wed,Thur,Fri,Sat,Sun" ; //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if ( istradeday(tradingdays) == false ) return(0) ; //expert code return(0); } //+------------------------------------------------------------------+ string ToUpperCase(string sText) //with thanks to thread https://forum.mql4.com/4891 { int iLen=StringLen(sText), i, iChar; for(i=0; i < iLen; i++) { iChar=StringGetChar(sText, i); if(iChar >= 97 && iChar <= 122) sText=StringSetChar(sText, i, iChar-32); } return(sText); } //+------------------------------------------------------------------+ bool istradeday(string OkDays) { datetime now=iTime(Symbol(),PERIOD_M1,0) ; int today=TimeDayOfWeek( now ) ; //Using Time[0] is a possible error int result ; string chkday="" ; switch ( today ) { case 0 : chkday="SUN" ; break ; case 1 : chkday="MON" ; break ; case 2 : chkday="TUE" ; break ; case 3 : chkday="WED" ; break ; case 4 : chkday="THU" ; break ; case 5 : chkday="FRI" ; break ; case 6 : chkday="SAT" ; break ; } OkDays=ToUpperCase(OkDays) ; result = StringFind(OkDays,chkday,0) ; if (result<0) return( false ) ; //day not found in list return( true ) ; }
Some simplification possible.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone, i need help to add time filter on this EA.
I only need:
Thanks if you can help me...
Gianluca Ferri