Need Help: Server Time v. Local Time, dealing with day light saving...

Back to topics list To post a new topic, please log in or register
Tingmore 2015.01.03 01:35

Hi all,

I currently run an EA on a VPS based in London. This EA begins trading at the open of the ASX 200 (Australia) futures market. That is, at the opening time of the market it starts gathering information to assess possible trades. The problem is that twice a year there is day light saving in London and twice a year (different dates) there is day light saving in Australia.

Is there any easy way for the EA to accommodate such changes in time into the EA automatically? At the moment I have a user input which asks for the opening and closing time of the market, which I manually have to change 4 times a year. Is there a way I can query when the market opens from a symbol? Or even if I can determine when the first tick of the week is, I can extrapolate from that what the server time will be when the market opens... Any help would be appreciated.


GreenMoney 2015.01.03 05:32 #

The easy answer is: yes, an EA can be programmed to recognize daylight saving time changes.

The more difficult part is deciding how to implement such code.  The KISS (Keep It Simple, Stupid) method is to code the rule.  Aussie DST starts on the first sunday in October and ends on the first sunday in April.  So simply code a function that checks to see if the server date/time is between the first sunday in October and the first sunday in April.  Same with European DST (which starts on the last sunday of March and ends on the last sunday of October).  Once you code the rule, the code should determine DST independent of what year it is.  I previous coded some examples, see discussion starting here.  An issue that you need to consider is what your code needs to do when aussie DST and european DST overlap. 

gooly 2015.01.03 21:27 #

As the time-shifts happens only over the weekend you can easily find the actual time-shift (with DST and ...) of your broker for the next week by checking the difference every Sunday at Forex-Session start:

// not tested (typecasting!)
int SecTimeShift_Broker_GMT = int(TimeCurrent() - TimeGMT());
int SecTimeShift_Broker_PC  = int(TimeCurrent() - TimeLocal());

It could be necessary to add some rounding due to a delay and/or the clocks. 

Back to topics list  

To add comments, please log in or register