Starts EA just after 6am GMT. How could I do this?

 

Hello everybody, I would like that my ea just start after 6am GMT (3am local time). How could I do this?

I did with the code below in init() function, but I guess that there are something easier.

int init()

{

int secondsNow = TimeLocal();

for(int i=1;i<=86400;i++) if(TimeDay(secondsNow+i) == TimeDay(secondsNow)+1) break;

Sleep((i+3*3600)*1000);

/* We can check with this:

int rightTime = TimeLocal()+i+3*3600;

Alert(TimeDay(rightTime)+"/"+TimeMonth(rightTime)+"/"+TimeYear(rightTime)+" "+TimeHour(rightTime)+":"+TimeMinute(rightTime));

*/

}

 

i put the code inside a time checking if function. works for me and pretty easy.

    if( (Hour()>=8 && Minute()>=0) && (Hour()<17 && Minute()<=59) )

      {

      ukSession="MKT OPEN";     

      }
 
double HourDayStart = 6;  //if brokertime not GMT then set the time to right timezone
/*
.
.
.
.
.
*/



//---- New Day   
   datetime now = Time[0],
         bod = now - now % 86400;  // Beginning of the day
   double HourDay = bod + HourDayStart * 3600;
                  
if(TimeCurrent()< HourDay)return(0); 
 
Rodorush:

Hello everybody, I would like that my ea just start after 6am GMT (3am local time). How could I do this?

I did with the code below in init() function, but I guess that there are something easier.


Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.

 
 

deVries:

double HourDayStart = 6; 
double ?
 

Hello everybody, thank you very much for all suggestions. All of them were very useful and I implemented a mix of solutions. All the best for you.

Reason: