Please, how I can check if market is open or closed in MT5, I cant find answer.
something similar to MT4 - MarketInfo(Symbol(),MODE_TRADEALLOWED) this command doesn't exist in MT5 anymore.
MarketInfo(Symbol(),MODE_TRADEALLOWED) in MT4 isn't reliable.
If you want to check Opened/Closed market you should use these functions together (both in MT4 and MT5):
SymbolInfoSessionTrade() => to find the last session start/end time
SymbolInfoInteger(_Symbol,SYMBOL_TIME) => to find out the last known tick time for the symbol
TimeCurrent() and TerminalInfoInteger(TERMINAL_CONNECTED) => to find out if the server is "ON"
Thank you for answer,
I dont know if mentioned command isn't reliable, but it was working
SymbolInfoSessionTrade() show nonsense times and counting back difference between last tick and current time seems to be not reliable to me, it doesn't meen that market is closed.
Why not reliable ?
Below is a log from a script I created to show you the reliability of MarketInfo(Symbol(),MODE_TRADEALLOWED). Both was run (as you can see) at this weekend (Market is closed) but EURUSD looks like the market is opened (by MarketInfo(Symbol(),MODE_TRADEALLOWED)).
2018.03.11 15:15:41.555 Script DAX_ecn,M15: Symbol: DAX_ecn ; Trade allowed: false ; Session trade from: 09:00:00 ; Session trade to: 22:59:00 ; Current time: 23:57:59 ; Last tick time: 22:59:59 ; Local time: 15:15:412018.03.11 15:16:58.792 Script EURUSD_ecn,M15: Symbol: EURUSD_ecn ; Trade allowed: true ; Session trade from: 00:06:00 ; Session trade to: 23:58:00 ; Current time: 23:57:59 ; Last tick time: 23:57:59 ; Local time: 15:16:58
SymbolInfoSessionTrade() show me correct data (what do you mean by nonsense times?) see the log above in my answer to Alain.
It's up to you. If you discover easier and reliable way, let me know.
It's up to you. If you discover easier way, let me know.
Sorry, my fault, timezone offset confused me a bit
yes, SymbolInfoSessionTrade() should be fine if it shows all and correct data
Thank you for help
Yes it should return when the market is open/close but is the documentation reliable ?
I am using it in some EA with some brokers and CFDs symbols and it's reliable while SymbolInfoSession() is not available.
And therefore the most reliable way I know is using the all functions I mentioned in my first answer.