Only trade between 8 am and 11 am new-york time

 
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.
 
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.
 

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.