How can I find market Open or Close?
dunction GetLastError()? What value return function? Or other function/way? Other solution?
What do you mean exactly by Market Open???
Do you mean the opening price of each week? If so, get the info using:
Specifying the weekly bar
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.
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 ?
"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 .
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.
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