TimeCurrent() and TimeTradeServer() functions - page 2

 
Alain Verleyen:
You can calculate the current GMT offset of the broker server, but it doesn't say you anything about the past.

Is it common for a broker trade server to change the GMT offset it is using? I have never heard of this happening.

 
emerson2102: Is it common for a broker trade server to change the GMT offset it is using? I have never heard of this happening.

I don't think it is common, but it has happened to me once.

 
emerson2102:

Is it common for a broker trade server to change the GMT offset it is using? I have never heard of this happening.

With many brokers twice a year due to  Daylight Savings time 

 
Keith Watford: With many brokers twice a year due to  Daylight Savings time 

No, we were referring to actual time zone change and not Daylight Savings change.

I once had a broker close shop in Portugal and move all accounts to their office in Latvia, changing timezone from WET/WEST to EET/EEST.

 
Fernando Carreiro:

No, we were referring to actual time zone change and not Daylight Savings change.

I once had a broker close shop in Portugal and move all accounts to their office in Latvia, changing timezone from WET/WEST to EET/EEST.

Wow, did they at least notify their customers about it?
 
emerson2102: Wow, did they at least notify their customers about it?
Yes, obviously, several months in advance actually! And were super helpful with their customers during the transition. They did everything so as not to lose the customer base.
 

Hi, 

So, for example, if I'm trying to send a message in a exactly time using "SendNotification" and I'm not sure "Server Time" will be available because the market could be closed.

In this case it is better use TimeTradeServer instead of TimeCurrent() ?


Code Example:

datetime last_vps_check=0;

void OnTick()
  {   
   MqlDateTime cur_str;
   TimeTradeServer(cur_str);
   if(!MQLInfoInteger(MQL_TESTER))
     {
      if(TimeTradeServer()>_IntToTime(6,45) && (cur_str.day_of_year>last_vps_check))
        {
         SendNotification("VPS Running");
         last_vps_check=cur_str.day_of_year;
        }
     }
  }

datetime _IntToTime(int hour, int minutes)
  {
   string time = IntegerToString(hour) + ":" + IntegerToString(minutes);

   MqlDateTime time_str;
   TimeToStruct(StringToTime(time),time_str);

   MqlDateTime cur_str;
   TimeTradeServer(cur_str);
   MqlDateTime str;
   str.day=cur_str.day;
   str.year=cur_str.year;
   str.mon=cur_str.mon;
   str.hour=0;
   str.min=0;
   str.sec=0;
   datetime day=StructToTime(str);
   if(day==0)
     {
      Alert("Open D1 chart on "+Symbol());
      return(TimeCurrent()+60*60);
     }
   return (day+time_str.hour*60*60+time_str.min*60);
  }
Reason: