Download MetaTrader 5

Market Open or Close - how can I find it?

To add comments, please log in or register
Pavel Soukup
560
Pavel Soukup  

Hi,

How can I find market Open or Close?

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

Thank you.

Paul B
175
Paul B  

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

Pavel Soukup
560
Pavel Soukup  

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.

Paul B
175
Paul B  
Your EA will only work if the market is open. How can something that is not receiving ticks to enable processing carry out any checks???
onewithzachy
2271
onewithzachy  
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

Pavel Soukup
560
Pavel Soukup  

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

Pavel Soukup
560
Pavel Soukup  

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

return 1 - if market open else return 0

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

Ricardo1
181
Ricardo1  
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. :)

Gustavo Hennemann
194
Gustavo Hennemann  
Ricardo1:


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. :)

Hi guys,

There is no MarketInfo() in MT5. Also, this kind of solution works for holidays and days off?

Thanks

To add comments, please log in or register