Market Open or Close - how can I find it?

Back to topics list To post a new topic, please log in or register
avatar
193
endy5 2012.06.19 08:13
 

Hi,

How can I find market Open or Close?

dunction GetLastError()? What value return function? Or other function/way? Other solution?

Thank you.

 
avatar
76
Paul_B 2012.06.19 10:47 #
 

What do you mean exactly by Market Open???

Do you mean the opening price of each week? If so, get the info using:

https://docs.mql4.com/series/iOpen

Specifying the weekly bar

 
avatar
193
endy5 2012.06.19 11:57 #
 

I don´t think open or close price. I mean if market open or close.

example: Sometimes is market closed during day (comodities, futures, softs etc.) Every market have individual open-close hours. And I need my EA identified if market open or close.

 
avatar
76
avatar
1252
onewithzachy 2012.06.19 12:54 #
 
endy5:

Hi,

How can I find market Open or Close?

dunction GetLastError()? What value return function? Or other function/way? Other solution?

Thank you.

In a loop, if the last server time is the same with the current server time while the last local time is different with current local time, and you have connection, then market is close.

Got it ?

:D

 
avatar
193
endy5 2012.06.19 13:11 #
 

"Your EA will only work if the market is open"

Yes. I know it. But I need trading more markets at the same time and ALL MARKETS MUST BE OPEN (gold, oil, S&P, fx)

I do not want manually set open/close hour for every markets. I want to do automatically inside my code EA .

 
avatar
193
avatar
1252
onewithzachy 2012.06.22 12:23 #
 
endy5:

I find solution for me: MarketInfo(Symbol(), MODE_TRADEALLOWED);

return 1 - if market open else return 0

When market close, there is no tick, so in the end you still need a loop.

:D

avatar
18
Ricardo1 2015.03.23 00:03 #
 
endy5:

I find solution for me: MarketInfo(Symbol(), MODE_TRADEALLOWED);

return 1 - if market open else return 0


Although some 3 years after the fact, I found your solution when searching for an answer to the same question and let me congratulate you. It is superb! And of course it doesn't matter that there is no tick if you are using OnTimer() (instead of start() or OnTick()). I tried with IsTradeAllowed() but it didn't work, and so I thought it wouldn't work with MarketInfo but, alas, it does. There are other reasons which could cause trading not to be allowed but, as far as I know, your solution is as close as it gets. :)


Back to topics list  

To add comments, please log in or register