Broker-independent time-routine: LibGMT.h

Post Reply
mbkennel
Trader
Posts: 29
Joined: Tue Dec 20, 2011 5:40 am

Broker-independent time-routine: LibGMT.h

Post by mbkennel »

I'm reposting here a useful "include" library called LibGMT.h. It does broker-independent time computations. You can get local time & local day in GMT, London, New York & Tokyo, and it adjusts for daylight saving (with hard coded tables through about 10 years from now). It requires that your local Windows computer is set to proper timezone & time (most are & automatically updated), and that you allow DLL calls when running an indicator/EA.

Use: stick it in experts\include folder. Use #include <LibGMT.h> in your EA/indi code.

And yes I wrote it with my own ten fingers. Copyrighted & GPL licensed, meaning that any EA/indi which uses it must also be publicly released under compatible conditions. Contact me for terms if you have a different requirement.

From the comments:

Code: Select all

UTILITY FUNCTIONS
 
   datetime GMTseconds()       
            return the datetime (seconds since 1/1/1970) for GMT time zone.
   void MakeDayHHMM(datetime dt, int& day_of_week, int& hhmm) 
            set day_of_week and hhmm from 'dt'.
            
 USEFUL FUNCTIONS      
   
 void GetLocalDayHHMM(int& day_of_week, int& hhmm)
 void GetGMTDayHHMM(int& day_of_week, int& hhmm)
 void GetNewYorkDayHHMM(int& day_of_week, int& hhmm) 
 void GetLondonDayHHMM(int& day_of_week, int& hhmm) 
 void GetTokyoDayHHMM(int& day_of_week, int& hhmm) 

These get the day of week & time with respect to the local (computer's local),
GMT, NYC, London and Tokyo. 'hhmm' means an integer of 100*hour + minute, making
comparisons easy.

Look what function is NOT present: the server time which controls all the charts.
Why?  Because there is no automatic way to know the broker's time zone & daylight
saving adjustment.

You do not have the required permissions to view the files attached to this post.
"It is a capital mistake to theorize before one has data." Sir Arthur Conan Doyle.
"If your experiment needs statistics, you ought to have done a better experiment" Lord Rutherford.
Dozer
Trader
Posts: 25
Joined: Wed Nov 16, 2011 4:32 pm

Re: Broker-independent time-routine: LibGMT.h

Post by Dozer »

Very useful library. Thank you! :D
Post Reply

Return to “Coders Hangout”