Hi,
Code:
if(isTradeTime("07:00","17:00") == false)
{
// ab hier OrderClose()-/TP-Routine
return(0);
}
// ab hier normale Handelsroutine, da wir innerhalb des Zeitfensters sind
/**
* Checks if we are in the given timeframe
* e.g. string timebegin = "08:00"
* return(true) if localtime = 8:00
*/
bool isTradeTime(string begin, string end)
{
if(begin == "" || end == "")
return(false);
// TODO testen ob int reicht
datetime time0 = StrToTime(begin);
datetime time1 = StrToTime(end);
if(time1 > time0)
return(false);
// saturday
if(TimeDayOfWeek(TimeLocal()) == 6)
return(false);
// sunday 23:00 begin
if(TimeDayOfWeek(TimeLocal()) == 0 && TimeLocal() < StrToTime("23:00"))
return(false);
if(TimeLocal() >= time0 && TimeLocal() <= time1)
return(true);
return(false);
}
ungetestet und an eigene Bedürfnisse bitte anpassen.
Gruss
sandmann