Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? Order your application from a developer!
fx_ta
57
fx_ta 2013.06.18 23:10 

Hi all

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.

Thanks

 FX_TA 

Alain Verleyen
Moderator
28605
Alain Verleyen 2013.06.19 08:14  
fx_ta:

Hi all

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.

Thanks

 FX_TA 

Maybe you can begin to read the documentation.
Tucu Titus Corneliu
594
Tucu Titus Corneliu 2014.02.23 14:51  
angevoyageur:
Maybe you can begin to read the documentation.

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 ! 

Rogerio Figurelli
Moderator
36176
Rogerio Figurelli 2014.02.23 15:27  
Duras:

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.

Documentation on MQL5: Market Info / SymbolInfoSessionQuote
Documentation on MQL5: Market Info / SymbolInfoSessionQuote
  • www.mql5.com
Market Info / SymbolInfoSessionQuote - Documentation on MQL5
Tucu Titus Corneliu
594
Tucu Titus Corneliu 2014.02.23 18:08  
figurelli:

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.

Thank you very much, Rogerio, you are very kind !
Rogerio Figurelli
Moderator
36176
Rogerio Figurelli 2014.02.23 18:13  
Duras:
Thank you very much, Rogerio, you are very kind !
Thanks, you are welcome.
Alain Verleyen
Moderator
28605
Alain Verleyen 2014.02.23 19:05  
Duras:
Thank you very much, Rogerio, you are very kind !

And me, I am not kind :-(


Tucu Titus Corneliu
594
Tucu Titus Corneliu 2014.02.23 19:51  
angevoyageur:

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 !

Titus 

Rogerio Figurelli
Moderator
36176
Rogerio Figurelli 2014.02.23 20:27  
Duras:

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 !

Titus 

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.

Alain Verleyen
Moderator
28605
Alain Verleyen 2014.02.23 20:31  
Duras:

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 !

Titus 

Ah you need an elegant solution :-)

What about checking TimeCurrent(), if there is no tick Market is closed.

Jinsong Zhang
14645
Jinsong Zhang 2014.02.24 04:39  
angevoyageur:

Ah you need an elegant solution :-)

What about checking TimeCurrent(), if there is no tick Market is closed.

some reasons cause "no tick" when you call TimeCurrent(): disconnect, symbol not so active... so MarketInfo(Symbol(), MODE_MARKETOPEN) will be good and clear
/ /12
To add comments, please log in or register