MQL4 How to determine brokers Timezone

 

How can I find the timezone that my broker resides in?

I can get the time of the last tick using something like:

SymbolInfoTick(Symbol(), last_tick)

That tells me the time of the tick, but not the time zone.

I've looked at various AccountInfo, MarketInfo and SymbolInfo functions, but I can't find anything that simply tells the timezone that the broker resides in.

 
crazyh:

How can I find the timezone that my broker resides in?

I can get the time of the last tick using something like:

That tells me the time of the tick, but not the time zone.

I've looked at various AccountInfo, MarketInfo and SymbolInfo functions, but I can't find anything that simply tells the timezone that the broker resides in.

Take your guess


 
Fernando Morales:

Take your guess


As I said in the title of the my post, I'm using MQL4... not 5.
Secondly, I already did RTFM... just not every single last letter of it.

Since I checked everything that seemed obvious, asking a knowledgable body of more experienced people seemed like a good idea.

Also, none of those time functions help, because they are all based on modified Unix epocs. They don't store any information about time zone.

They modify the epoc internally somehow, then don't store the timezone ( atleast not anywhere that I can find ).

So yeah, I could try to figure out the time zone by comparing it to TimeGMT() and hoping for the best... but daylight savings ruins that idea.

Some places observe DST, some don't. Different places may observe it at different times and possibly even in different amounts.

It would be pretty cool if MT4 could just tell me the time zone so that I wouldn't have to guess.

 
crazyh:

As I said in the title of the my post, I'm using MQL4... not 5.
Secondly, I already did read the documentation... just not every single last letter of it.

Since I checked everything that seemed obvious, asking a knowledgeable body of more experienced people seemed like a good idea.

I don't know what answer you are expecting.

TimeGMTOffset()

will give you the local time offset from GMT.

Many people (me included) will click on unread posts and the title does not always register so please include important information in your posts, not just the title.

If the subject is regarding MQL4 then please post the topic in the MQL4 sub-forum.

If I had noticed this before I would already have moved this topic. 

I will move it now.

 
Ok, thanks for the info... sorry for posting in the wrong place.

According to the MQL4 manual at: https://docs.mql4.com/dateandtime/timegmtoffset

TimeGMTOffset() =  TimeGMT() - TimeLocal()

Which means it tells you nothing about the broker. It just telling the difference between your local machine and GMT.

So I'm still not able to find anything that tells the difference between GMT and the broker.

I'm hoping that there is a way to do this. I'd rather not have to do it manually then hope for the best come DST.

TimeGMTOffset - Date and Time - MQL4 Reference
TimeGMTOffset - Date and Time - MQL4 Reference
  • docs.mql4.com
TimeGMTOffset - Date and Time - MQL4 Reference
 
crazyh:
Ok, thanks for the info... sorry for posting in the wrong place.

According to the MQL4 manual at: https://docs.mql4.com/dateandtime/timegmtoffset

TimeGMTOffset() =  TimeGMT() - TimeLocal()

Which means it tells you nothing about the broker. It just telling the difference between your local machine and GMT.

So I'm still not able to find anything that tells the difference between GMT and the broker.

I'm hoping that there is a way to do this. I'd rather not have to do it manually then hope for the best come DST.

Sorry, typo.

You know the difference between your local time and GMT and you can use the difference between TimeLocal() and your broker's time to calculate the GMT offset.

 
crazyh: How can I find the timezone that my broker resides in?

You have to ask them. Comparing to UTC doesn't tell you anything about DST.

Chart times are broker times.
 
I suggest reading this article.



 
crazyh #:
Ok, thanks for the info... sorry for posting in the wrong place.

According to the MQL4 manual at: https://docs.mql4.com/dateandtime/timegmtoffset

TimeGMTOffset() =  TimeGMT() - TimeLocal()

Which means it tells you nothing about the broker. It just telling the difference between your local machine and GMT.

So I'm still not able to find anything that tells the difference between GMT and the broker.

I'm hoping that there is a way to do this. I'd rather not have to do it manually then hope for the best come DST.

int brokerGMT = TimeHour((TimeCurrent()-TimeGMT()));
 
Pavel Shutovskiy #:
  1. Code fails if TZ is less than UTC, e.g. TimeHour(-1)
  2. Code fails if brokers clock is seconds less compared to UTC.
  3. int brokerTZ = TimeCurrent() - TimeGMT() + 1800) / 3600; // Nearest hour, no jitter.

 
William Roeder #:
  1. Code fails if TZ is less than UTC, e.g. TimeHour(-1)
  2. Code fails if brokers clock is seconds less compared to UTC.

Yes, you're right I didn't take that into account

I wrote the first thing that came to mind

Reason: