Please help on my code?

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2016.07.18 07:39
 

I want to run my ea on following times:

00:15 to 20:30

i have tried following logic. but it does not accept the times like 0015, which takes as 15:00

int datetime800 = TimeCurrent();
    int hour0 = TimeHour(datetime800);
    
    if ((HoursMinutesFrom < HoursMinutesTo && hour0 >= HoursMinutesFrom && hour0 < HoursMinutesTo) ||
    (HoursMinutesFrom > HoursMinutesTo && (hour0 < HoursMinutesTo || hour0 >= HoursMinutesFrom)))


avatar
164
rod178 2016.07.18 07:44 #
 
sheriffonline:

I want to run my ea on following times:

00:15 to 20:30

i have tried following logic. but it does not accept the times like 0015, which takes as 15:00


enter the time(s) as text (string)

convert the string to datetime 

avatar
13006
WHRoeder 2016.07.18 16:05 #
 
Or define your times.
#define HR0015   900 // 15 * 60
#define HR2030 73800
#define HR2400 86400 // 24 * 3600
datetime now = TimeCurrent();
datetime tod = now % HR2400; // Time of day
if(now >= HR0015 && now < HR2030) ...

avatar
872
eevviill 2016.07.18 21:59 #
 
https://www.mql5.com/en/forum/91432/page2#comment_2662182
Back to topics list  

To add comments, please log in or register