-
StringToTime(start_time); StringToTime(end_time); StringToTime(dt);
These lines do nothing. You are throwing the results away. Simplify:string start_time = StringToTime(starting_time); string end_time = StringToTime(ending_time);
-
There is no time 24:00. Converting to a string results in a wrong result. Replacing with 23:59:59 would work.
-
Your start time is 00:00 not 24:00.
-
Rename your function. It returns true if it is time to trade, not time to sleep.
-
Stop using strings as inputs, you can't optimize them. Replacing the strings with a double start_hour simplifies everything.
bool tradeTime() { int begin = int( starting_hour * 3600); int end = int( ending_hour * 3600); int now = time(); return begin <= end ? begin <= now && now < end : begin >= now || now < end; }
Find bar of the same time one day ago - MQL4 programming forum (2017)
Increase Order after stoploss - MQL4 programming forum #1.3 (2017)
- These lines do nothing. You are throwing the results away. Simplify:
-
There is no time 24:00. Converting to a string results in a wrong result. Replacing with 23:59:59 would work.
-
Your start time is 00:00 not 24:00.
-
Rename your function. It returns true if it is time to trade, not time to sleep.
-
Stop using strings as inputs, you can't optimize them. Replacing the strings with a double start_hour simplifies everything.
Find bar of the same time one day ago - MQL4 programming forum (2017)
Increase Order after stoploss - MQL4 programming forum #1.3 (2017)
Appreciate it!!!
-
Stop using strings as inputs, you can't optimize them. Replacing the strings with a double start_hour simplifies everything.
-
bool tradeTime() { int begin = int( starting_hour * 3600); int end = int( ending_hour * 3600); int now = time(); return begin <= end ? begin <= now && now < end : begin >= now || now < end; }
What a nice neat code. Hope I understood it correctly - the last line should be
: begin <= now || now < end;
?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi.
I want to run it during 24 hours.
If I set it up as following, EA does not work.
Start time=24:00
End time=24:00
What should I change it?
If I remove these code, it does not compile it either.
Thanks in advanced.