How to check Market Open/Closed in MT5 ?

 

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.

Thank you

 
Petr Jirousek:

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.

Thank you

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"

 
Petr Nosek:

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.

 
Petr Nosek:

MarketInfo(Symbol(),MODE_TRADEALLOWED) in MT4 isn't reliable.

...

Why not reliable ?

 
@Petr Nosek  who told you MT4

MarketInfo(Symbol(),MODE_TRADEALLOWED) in MT4 is not working,are you new to mt4 or just trying to do what you can't do..
 
Alain Verleyen:

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:41
2018.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

 
Petr Jirousek:

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.

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.

 
chudanever:
@Petr Nosek  who told you MT4

MarketInfo(Symbol(),MODE_TRADEALLOWED) in MT4 is not working,are you new to mt4 or just trying to do what you can't do..
I didn't want to answer but... Be sure I'm not new to mt4. With your mql knowledge I wouldn't try anything. The best example of your knowledge: https://www.mql5.com/en/forum/230966
 
Petr Nosek:

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 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

 
Petr Nosek:

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:41
2018.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

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.

 
Alain Verleyen:

Yes it should return when the market is open/close but is the documentation reliable ?

And therefore the most reliable way I know is using the all functions I mentioned in my first answer.

Reason: