Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | Function for checking whether the market is open for trading at the moment by the current symbol

MetaTrader Experts, Indicators, Scripts and Libraries
bool CheckTradeAllowed()    {     MqlDateTime date_cur;     TimeTradeServer(date_cur);     datetime seconds_cur = date_cur.hour * 3600 + date_cur.min * 60 + date_cur.sec;     int i = 0;     while(true)       {        datetime seconds_from = {}, seconds_to = {};        if(!SymbolInfoSessionTrade(Symbol(), (ENUM_DAY_OF_WEEK)date_cur.day_of_week, i, seconds_from, seconds_to))           break;        if(seconds_cur > seconds_from && seconds_cur < seconds_to)           return true;        ++i;       }     return false;    }  

57948