stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

LibTime
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3847
Page 1 of 1
Author:  renexxxx [ Wed Sep 24, 2014 11:06 pm ]
Post subject:  LibTime

Here is a library (actually an include file) for 'calculating' the correct session times. This may come in handy for all the coders who need to refer in their code to the session opening times (such as London Open, New York Open etc.), but do not want to bother their users with input parameters for setting GMT offsets etc.

The code makes use of the function TimeGMT() that was introduced in Empty4-buid 600+, and as such does not rely on the broker time (so you don't need to worry about your broker switching On/Off DST).

Eg. if you want to open a few trades within the first five minutes of London Open, you would use this code:

UPDATE: This code has now been updated. TimeGMT() is actually the local PC time +/- the GMT Offset. The time on the CNS VPS server is 6 minutes ahead of the official time, so we can't use TimeGMT(). I updated LibTime (please re-download) to include the function TimeCurrentGMT() which gives the br0kers time in GMT. The code in the EA will now look like:

Code: Select all

#include <LibTime.mqh>

   if ( ( TimeHour( TimeCurrentGMT() ) == LondonOpenHourGMT() ) && ( TimeMinute( TimeCurrentGMT() ) < 5 ) ) {
      tradeEUR();
   }
Hope this will be useful and that it will help towards reducing the endless questions about "the time" ...

R.
Author:  dydynamic [ Thu Sep 25, 2014 1:35 am ]
Post subject:  LibTime

hi,
if i want to trade only the EUR Pairs in London seession how do i code it in your code?
thanks
Author:  renexxxx [ Thu Sep 25, 2014 2:03 am ]
Post subject:  LibTime

dydynamic ยป Thu Sep 25, 2014 11:35 am wrote:hi,
if i want to trade only the EUR Pairs in London seession how do i code it in your code?
thanks
Hi dydynamic,

You could do something like this in the attached file.

Cheers ... R.
Author:  dydynamic [ Thu Sep 25, 2014 8:41 am ]
Post subject:  LibTime

thank you so much. you are a darling . :clap: :clap: :clap: :yahoo: :good: :hi: :smile: :xm: :xm: :xm:
All times are UTC Page 1 of 1