Download MetaTrader 5
To add comments, please log in or register
You can test an application before buying it. Find out how to do that!
Pavel Soukup
559
Pavel Soukup 2012.06.19 06:13 

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
173
Paul B 2012.06.19 08: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

Pavel Soukup
559
Pavel Soukup 2012.06.19 09: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.

Paul B
173
Paul B 2012.06.19 10:06  
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
2274
onewithzachy 2012.06.19 10: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

Pavel Soukup
559
Pavel Soukup 2012.06.19 11: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 .

Pavel Soukup
559
Pavel Soukup 2012.06.22 06:17  

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

return 1 - if market open else return 0

onewithzachy
2274
onewithzachy 2012.06.22 10: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

Ricardo1
161
Ricardo1 2015.03.22 23: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. :)

/
To add comments, please log in or register