Download MetaTrader 5
To add comments, please log in or register
Learn operation principles of Trading Signals for MetaTrader.
clemonsla
9
clemonsla 2013.03.28 22:30 
Trying to code my EA to only trade in the 3 hours between 8 am and 11 am EST time. Can someone show me some light or point me to an article please? thank you.
Alain Verleyen
Moderator
30635
Alain Verleyen 2013.03.28 22:47  
clemonsla:
Trying to code my EA to only trade in the 3 hours between 8 am and 11 am EST time. Can someone show me some light or point me to an article please? thank you.

See here ;-)

Or may be this.

Amazon Best Sellers: Best Electrical Timers
  • reviews: 45
  • www.amazon.com
Discover the best Electrical Timers in Best Sellers. Find the top 100 most popular items in Amazon Home Improvement Best Sellers.
Jian Chen
Moderator
3618
Jian Chen 2013.03.29 00:38  

You may use "TimeGMT" function to get the current GMT time. Then convert it to US EST time (NY time) and compare it with the time that you want to trade. In the meantime, you may need to consider the daylight savings.

For example:

bool IsGoodTimeToTrade()
{
    int tStart = 8, tEnd = 11;
    int offset = -5; // EST timezone
    
    if(TimeDaylightSavings()!=0) // need to consider daylight savings?
        offset++;

    MqlDateTime gmtTime;
    TimeGMT(gmtTime);
    if(gmtTime.hour>=tStart-offset && gmtTime.hour<tEnd-offset)
        return true;
    else
        return false;
}

Please note the above code doesn't work with all settings (the "tStart-offset" or "tEnd-offset" may greater than 24 or less than 0, if we choose different start/end/offset values). It's just an example.

/
To add comments, please log in or register