Time filter to add...please help!!

 

Hi everyone, i need help to add time filter on this EA.

I only need:

MON = TRUE/FALSE;
TUE = TRUE/FALSE;
WED = TRUE/FALSE;
THU = TRUE/FALSE;
FRI = TRUE/FALSE;
SAT = TRUE/FALSE;
SUN = TRUE/FALSE;
TRADE FROM = 8;
TRADE TO = 16;


Thanks if you can help me...

Gianluca Ferri

Files:
 
Here.
 

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.
 
Or my code
Reason: