-
extern string StartTime = "01.00"; //EA starts hour extern string EndTime = "23:00"; //EA stops hour
When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours and fraction can be inputs.
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26) Your code if((dt.day_of_week ==0 && Sunday) || ⋮ (dt.day_of_week ==6 && Saturday)) return true; return false;
Simplified return (dt.day_of_week ==0 && Sunday) || ⋮ (dt.day_of_week ==6 && Saturday);
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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,
I'd like to confirm my logic to limiting my trading EA to given hours (start to finish) and days.
I'm grateful if someone can confirm it or correct it if there's any problem with the code above.
Thanks.