I would like to check in the expert advisor if the markt is open/close. What's the easiest way to do that?
I don't want do check that over time. I also need to know when the market open again after the short close every day at 11pm.
Well, actualy I have the same question/problem ... and I've read the documentation. A straight answer followed by example (eventualy) would be nice, I could't figure myself such a test. SymbolInfoSessionTrade() does not realy do the job well enough.
I expected to find a request identifier for the MarketInfo() function that returns true/false but I couldn't find any. The only thing that I've found is ERR_MARKET_CLOSED but this error rises only if I try to open/close/delete/modify an order so it doesn't help me. The goal is not to have logs filled with this error on script infinite cycles that run permanently (including weekends).
Ideeas ? Thanks !
Hi Duras, my suggestions:
- Start with https://www.mql5.com/en/docs/marketinformation/symbolinfosessionquote (this is inside the documentation link provided by angevoyageur).
- Read this post https://www.mql5.com/en/forum/11298#comment_457826 and check the article https://www.mql5.com/en/articles/22, suggested by angevoyageur in the post.
Hope this can help you and fx_ta.
And me, I am not kind :-(
Ohhh, come ooonnn ... you are, too ... when you are present and responsive ! :D
Anyway, I looked over the suggested code in the links and the solution is far from elegant. I mean, I have to loop through the sessions of the day, pick the last one (I presume), check if I am between it's open and close time and get the answer. I wonder if I should test for connection as well. Ain't that too much ? Really, guyz, you are "heavy weight" in MQL and in this forum, maybe a little lobby towards MetaQuotes to introduce "MarketInfo(Symbol(), MODE_MARKETOPEN)" isn't such a bad ideea !
Thank you, both, very much indeed !
Duras, sorry the off-topic, but the hard part of Moderators here is that they are users too, despite people sometimes see them as oracles!To be honest, I did this same mistake in the past, but now as Moderator I see things different, because there are so many questions in this Forum that are absolutely repetitive and that just a previous search would be enough, that sometimes it's understandable that Moderators answers are not so straight or elegant.But the more relevant for me is that if you have hard to answer questions here, you can be sure you will find kind and wise users, like newdigital, RaptorUK, Malacarne and angevoyageur, just for instance, to solve your doubts or send you to the service desk :-)Actually, in my opinion, these guys are expecting such challenges.
Ah you need an elegant solution :-)
What about checking TimeCurrent(), if there is no tick Market is closed.