You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The only conclusion for everyone is try it yourself according to your needs, there is no universal solution by using a single function call.
Alain is correct—brokers have all sorts of wonky settings! I found one broker who specifies forex hours between two separate sessions.
As this thread is the top one to show up in Google, I will place this code here. It seems to work for two separate brokers for forex and odd symbols like an index fund that takes a 15 minute break on weekdays.
Caveat emptor.
Alain is correct—brokers have all sorts of wonky settings! I found one broker who specifies forex hours between two separate sessions.
As this thread is the top one to show up in Google, I will place this code here. It seems to work for two separate brokers for forex and odd symbols like an index fund that takes a 15 minute break on weekdays.
Caveat emptor.
hello Anthony, what is HR2400?
thanks
thanks for your answer William.
In MT5, PERIOD_D1=16408, so I think in MT5 the code should be HR2400=PeriodSeconds(PERIOD_D1)
regards
The method I use:
The method I use:
Not at all.
Why do you want to know when market is closed ? On Forex the open/close hours are well known, you can just check broker time, session time (I mean asian, europa, us sessions) and you will know if the market is open/close.
For metals or CFDS, you have sometimes a market close for 15 minutes or 1 hour, to know that the most reliable way is MarketInfo(symbol,MODE_TRADEALLOWED) (MT4).
For MT5 you can always use SymbolInfoSessionTrade().
Using last tick time is not really useful, as you can't make the difference between a closed market and a "slow" market.
I am working with a lot of customers and a lot of brokers, so I am talking in general, but of course I didn't check all brokers. Also it's probably always possible to find a broker who will provide data that contradicts the above.
Not sure why you are being condescending, but checking if market is closed or open is important for many trading strategies. The OP's question is clearly a concern for many developers.
I never said it's not important. I asked "why...?" in a given context. I also provided the solution.
How is your comment useful ?
MarketInfo(Symbol(),MODE_TRADEALLOWED) in MT4 isn't reliable.
If you want to check Opened/Closed market you should use these functions together (both in MT4 and MT5):
SymbolInfoSessionTrade() => to find the last session start/end time
SymbolInfoInteger(_Symbol,SYMBOL_TIME) => to find out the last known tick time for the symbol
TimeCurrent() and TerminalInfoInteger(TERMINAL_CONNECTED) => to find out if the server is "ON"
Hello Petr
Thank you very much for your input on how to check opened/closed markets. Very helpful.
I assume you subtract TimeCurrent() with SymbolinfoInteger(_Symbol, SYMBOL_TIME) and find out how long ago the last tick appeared.
May I ask how much time you let pass since the last tick before defining the market as closed?
I'm not very experienced, but I'm very curious on how experienced programmers do.