Hello,
need a function to detect if a market is closed for FX symbol .
My solution
bool market_closed(string symbol)
{
if(StringLen(symbol) > 1)
{
datetime begin=0;
datetime end=0;
datetime now=TimeCurrent();
uint session_index=0; // guess latest/current session
MqlDateTime today;
TimeToStruct(now,today);
if( SymbolInfoSessionTrade(symbol,(ENUM_DAY_OF_WEEK ) today.day_of_week,session_index,begin,end) == true)
{
if(now >= begin && now <= end)
return false;
return true;
}
}
return false;
}
does not work: date begin and end always are 1970-01-01.
Is this because the Symbol is a FX contract ?
Do i something wrong ?
Thank you