If you want help then please show your actual code for obtaining the session times as well as the log output from printing those values.
Hi all,
please see screenshot
I'm getting 00:00 for start and end
How can I determine that the market is open for trading?
Here is the list of all function with explanation, you can search for keywords: https://www.mql5.com/en/docs/function_indices
And here is (from there) the function about the session time: https://www.mql5.com/en/docs/marketinformation/symbolinfosessionquote
There is more on the left side...
- www.mql5.com
Hi all,
please see screenshot
I'm getting 00:00 for start and end
How can I determine that the market is open for trading?
That is not an issue if you are reading todays weekday as the datetime will never display 24:00 but 00:00 . So it is probably correct , however , if you want to make sure check a weekday that ends earlier , friday for example , where you should get 23:55
A proposition how to determine whether the market is open:
bool IsMarketOpen(const string symbol) { datetime from, to; datetime serverTime = TimeTradeServer(); MqlDateTime dt; TimeToStruct(serverTime,dt); const ENUM_DAY_OF_WEEK day_of_week = (ENUM_DAY_OF_WEEK) dt.day_of_week; const int time = (int) MathMod(serverTime,PeriodSeconds(PERIOD_D1)); int session = 0; while (SymbolInfoSessionTrade (symbol, day_of_week, session, from, to)) { if(time >=from && time <= to ) { return true; } session++; } return false; }Please adapt it for your needs
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
please see screenshot
I'm getting 00:00 for start and end
How can I determine that the market is open for trading?
This is the code on how I check