How to load a central time by an EA

 

Hello,


I'd like to have an EA load a centralized time from the internet. For example GMT.  How to do it?


Like TimeCurrent() but then from one location at the internet. Cause if you use TimeCurrent() it differs from broker to broker. I want to have one and the same time over different brokers, different machines and different locations, to store things to log files and later be able to compare things from a central time point.


Thanks!

 
HammerJack:

Hello,


I'd like to have an EA load a centralized time from the internet. For example GMT.  How to do it?


Like TimeCurrent() but then from one location at the internet. Cause if you use TimeCurrent() it differs from broker to broker. I want to have one and the same time over different brokers, different machines and different locations, to store things to log files and later be able to compare things from a central time point.


Thanks!

Use your PC time logic
Read  https://www.mql5.com/en/code/10459

Also Comments 

 
HammerJack:

Hello,


I'd like to have an EA load a centralized time from the internet. For example GMT.  How to do it?


Like TimeCurrent() but then from one location at the internet. Cause if you use TimeCurrent() it differs from broker to broker. I want to have one and the same time over different brokers, different machines and different locations, to store things to log files and later be able to compare things from a central time point.

With standard mql4 commands you caannot . . .
 

I've read it. I see TimeLocal() and TimeCurrent() being used. Meaning it will depend on broker and machine. I'd like to use one and the same source.



Example:

From:
GMT_TimeTransmitter

To:
VPS1 in London
VPS2 in New York
VPS3 in Amsterdam

I'm aware of the latency issues. Though to me it seems the best option.

 
@RaptorUK I thought so, was hoping that any of you had some solution for it. I can only think of clumsy solutions like running using one MT4 account and run this at every machine and use the TimeCurrent() from that as "central time" .
 
HammerJack:
@RaptorUK I thought so, was hoping that any of you had some solution for it. I can only think of clumsy solutions like running using one MT4 account and run this at every machine and use the TimeCurrent() from that as "central time" .
You might be able to find a WinAPI based solution or similar.
 
#import "kernel32.dll"
 
void GetLocalTime(int& LocalTimeArray[]);
void GetSystemTime(int& systemTimeArray[]);
int  GetTimeZoneInformation(int& LocalTZInfoArray[]);
bool SystemTimeToTzSpecificLocalTime(int& targetTZinfoArray[], int& systemTimeArray[], int& targetTimeArray[]);
 
#import
 

see the version at Donna forex forum in the link given in the comments you will see where to find the best version

log in there and you can download

in the indicator you have the logic to go from your local time to gmt

and how to calculate summertime in other countries 

 

I know it's not what you wan't but could you settle for a GMT offset extern variable which calculates all times back to GMT? It's what I do because it's quick and easy, just need to remember when changing broker.

extern int gmt_offset = 3;

datetime gmt_now = TimeCurrent()-gmt_offset*3600 // (60minutes times 60 seconds)

 I've also considered streaming GMT time from a free API from a website? (can I post a link?)

 
alladir:

I know it's not what you wan't but could you settle for a GMT offset extern variable which calculates all times back to GMT? It's what I do because it's quick and easy, just need to remember when changing broker.

 


summertime resetting is not the same weekend in different countries

some countries have summertime setting some have not 

when its winter here in netherlands then it is summer Australie 

 
@ Alladir, please go ahead and share the link, most curious what APi could be used for it.
 
extern int gmt_offset = 3;
datetime gmt_now = TimeCurrent()-gmt_offset*3600 // (60minutes times 60 seconds)
Or see my code for auto adjusting UTC offset (and NY dst.)