bool IsTimeOK = false;
if ( StartH > EndH )
if ( Hour() >= StartH || Hour() < EndH ) IsTimeOK = True;
if ( Hour() >= StartH && Hour() < EndH ) IsTimeOK = True;
if (IsTimeOK )
// you can trade here
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem. No free help 2017.04.21
Or pay someone. Top of every page is the link Freelance. Hiring to write script - General - MQL5 programming forum 2018.05.12
#define HR0900 32400
#define HR2030 73800 // (20*60+30)*30
datetime now = time();
bool isTimeOk = HR0900 <= now && now < HR2030;
Variations on a theme.
Hi JONI Spd, my five cents for MT4 would be to suggest you add this line in the ON INIT section of your EA:
EventSetTimer(60); // if you want to check every 60 seconds
Then add the below section, and code inside whatever you want to do every 60 seconds, or the frequency you setup above:
It seems that the OP wants to trade only at certain times of the day.
IF that is so, how will using the timer help?
Hi Keith, I see your point, actually Faeze Bakhshavesh showed the coding to check for "certain time of the day". No worries.