Here is a better timer code. I have not used it in a long time, but I think it will work. If you test and see that it doesn't, just let me know.
Use this for the user adjustable inputs. It uses hours and minutes. Keep the same format as the sample. So don't add a '.' instead of a ':' or a comma instead of a hyphen.
extern bool Use_Time_Restrictions = false;
extern string Times_Allowed = "08:00-16:00";
Here is the main function. If it returns true, then you can trade. If false, then no new trades.
bool TimeFilter()
{
if (!Use_Time_Restrictions)return(true);
if (Times_Allowed=="" || Times_Allowed==" ")return(true);
int pos = StringFind(Times_Allowed,"-",0);
datetime top = StrToTime(StringTrimLeft(StringTrimRight(StringSubstr(Times_Allowed,0,pos))));
datetime tcl = StrToTime(StringTrimLeft(StringTrimRight(StringSubstr(Times_Allowed,pos+1))));
if(top<tcl)
{
if(TimeCurrent()>=top&&TimeCurrent()<tcl)return(true);
else return(false);
}
else if (top>tcl)
{
if(TimeCurrent()>=top||TimeCurrent()<tcl)return(true);
else return(false);
}
return(true);
}