How to find out the "Market Opening Time" programmatically?

 
Hello all,

I think it is very important to know when a market in MetaTrader opens. I would like to write an indicator that prints the market opening time of the current symbol on every chart's top left corner. Therefore I need to find out the market opening time, e.g. 09:00-19:00 for EURABC, for a symbol.

Is there a way to find this the market opening time programmatically? I searched in "MarketInfo()", but no success.

Cheers,
McMurphy
 
You already have your indicator. Incoming ticks are a good indicator for an open market. Additionally you could visualize MODE_TRADEALLOWED
 
Hi Schnappi,

good idea.
Well, it seems that the start() function is called immediately when opening a chart. So showing the "last tick time" does not make sense when I see the time I have opened the chart.

But the MODE_TRADEALLOWED seems to be what I am searching for.
Unfortunately, the documentation does not say what makes a trade allowed? Is it only influenced by the fact whether the market is open/closed? Or might there be other factors (like e.g. no money on the account).

Cheers,
McMurphy
 
mcmurphy120 wrote >>
Hi Schnappi,

good idea.
Well, it seems that the start() function is called immediately when opening a chart. So showing the "last tick time" does not make sense when I see the time I have opened the chart.

But the MODE_TRADEALLOWED seems to be what I am searching for.
Unfortunately, the documentation does not say what makes a trade allowed? Is it only influenced by the fact whether the market is open/closed? Or might there be other factors (like e.g. no money on the account).

Cheers,
McMurphy


But take care, incomming ticks you have also outside the market opening time.
The market is open from sunday nigth to friday night (GMT).
What you mean - i guess - is the opening time of the different locations .. London, New York, Tokio....
Even London is closed you will recive ticks because Tokio is open for example.
You have to check yourself what time you will enable your EA.
In this case you will find here some new friends: https://docs.mql4.com/dateandtime
Reason: