GMT time

samjesse

Active Trader
Aug 30, 2011
118
0
27
Hi
Isn't this the right way to find the EST time?
It is not giving the correct EST time. please help.


thx

MQL5:
   dt_local = TimeLocal();
   EST = dt_local - (TimeGMTOffset()+5*3600);
 
Last edited by a moderator:

samjesse

Active Trader
Aug 30, 2011
118
0
27
After some thinking, I need to mark the EST 0 hr.

MQL5:
datetime dt_local;
datetime EST;
MqlDateTime dt_EST;
datetime EST_hr;
 
int OnInit()
  {
   SetIndexBuffer(0,iBuf,INDICATOR_DATA);
   ArraySetAsSeries(iBuf,true);
   EST = TimeLocal() + TimeGMTOffset()-4*3600;
   TimeToStruct(EST,dt_EST);      
   EST_hr = dt_EST.hour;  
 
 
   return(0);
  }
 
int OnCalculate(const int rates_total,
 ...
 
   ArraySetAsSeries(time,true);
 
   MqlDateTime dt_bar;
   for(int i=0; i<100; i++)
   {
      TimeToStruct(time[i],dt_bar);
      if(dt_bar.hour ==0) iBuf[i] = high[i]+0.2;
 
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
Last edited by a moderator: