LibTime

Post Reply
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

LibTime

Post by renexxxx »

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.
You do not have the required permissions to view the files attached to this post.
Last edited by renexxxx on Thu Sep 25, 2014 8:38 am, edited 1 time in total.
User avatar
dydynamic
Trader
Posts: 293
Joined: Fri Feb 28, 2014 4:19 pm

LibTime

Post by dydynamic »

hi,
if i want to trade only the EUR Pairs in London seession how do i code it in your code?
thanks
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

LibTime

Post by renexxxx »

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.
You do not have the required permissions to view the files attached to this post.
Last edited by renexxxx on Thu Sep 25, 2014 8:44 am, edited 1 time in total.
User avatar
dydynamic
Trader
Posts: 293
Joined: Fri Feb 28, 2014 4:19 pm

LibTime

Post by dydynamic »

thank you so much. you are a darling . :clap: :clap: :clap: :yahoo: :good: :hi: :smile: :xm: :xm: :xm:
Post Reply

Return to “Utilities”