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;
}
#57948ScriptsMetaTrader 5👁 2774 views
Function for checking whether the market is open for trading at the moment by the current symbol
A
Author
Anton IaroshenkoPublished date
May 22, 2025
📚Related Articles
← View other articles →#77077Scripts
Clock Diagnostic: TimeCurrent() freezes and steps backwards
ClockDiagnostic.mq5 reads TimeCurrent() and TimeLocal() every few seconds for a fixed observation window and reports the two failure modes of the server clock: it freezes when no t...
Joao Prata Silva YglesiasView detail →
#77073Scripts
Gold Hour Profile - when gold moves, and when the spread eats it
Every trader knows that some hours are better than others. This script answers that question with numbers from your own broker, instead of a general rule of thumb. For each hour of...
Petr KostalView detail →
#77063Scripts
OHLC Reality Check - at what stop distance does your backtest start lying?
Every backtest on 1 minute OHLC data makes one silent assumption: that inside a bar, price walked Open Low High Close on a bullish bar and Open High Low Close on a bearish one. It ...
Petr KostalView detail →