
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
Having experimented with all this in MT5, I have several questions. First though, I want to do this to ensure that no matter where on the globe my EA is used, I can always give an accurate answer to the question "Is the market for this symbol with this broker still active/open or not?" That applies to any symbol, any broker, any exchange, any global timezone in which a trader is trading. This includes Forex. I recognise that different brokers may have different times for the same symbol. That's fine, and all the more reason for this to be able to provide a reliably accurate determination of open/closed.
So, my questions:
Assume that the questions above are able to be answered fully and accurately, and for any symbol with any broker, and that the relevant session times and dates are correctly determined and specified in a known timezone.
I appreciate answers to the questions. Any code that is comprehensive for any symbol, any broker, any timezone used by a trader, would be most welcome.
Thanks.
Simple code I use
Simple code I use
Thanks, Chioma Obunadike.
Unfortunately, I don't think that is sufficient to meet the requirements I've specified. It's possible for the market to close at a time of day that is earlier than the end of the day and so there may be several hours before the day of the week changes during which the market is closed, but the test you make would say it is open because the day of the week has not yet changed. It also might fail when an exchange-based session crosses midnight in the trader's local timezone but the session is still open in the exchange timezone in the same (previous) day.
Further contributions would be most welcome.
Thanks.
Have a look on CloseOnWeekend_ea.mq5
Many thanks, amrali. That looks like it might be a good solution. You've obviously put in a lot of thought and effort! I will look at it in detail and respond there if need.
Thanks!
// IF it was first bar of the day at bar index ...
bool FirstBar( int index = 1 )
{
static datetime lastday = 0;
MqlDateTime CurBar;
TimeToStruct( iTime(NULL,0,index) , CurBar );
if(lastday==0){
lastday=CurBar.day;
return(false);
}
if(lastday!=CurBar.day)
{
lastday=CurBar.day;
return (true);
}
else
{
return(false);
}
}
For 'wonky' brokers symbol session.
In a single day, this market is closed between 00:00-00:59 and 23:16-23:29. Hence calling SymbolInfoSession() will only give you start time of 01:00 and end time of 23:15. From 23:15, the market is assumed closed, although still open on the broker.
The code provided above works well in this situation.
For 'wonky' brokers symbol session.
In a single day, this market is closed between 00:00-00:59 and 23:16-23:29. Hence calling SymbolInfoSession() will only give you start time of 01:00 and end time of 23:15. From 23:15, the market is assumed closed, although still open on the broker.
The code provided above works well in this situation.
This code is not correct to indicate a closed market in all situations. You can perfectly have 1 minute or more with any tick depending of the symbol trade and the trading session.
This code is not correct to indicate a closed market in all situations. You can perfectly have 1 minute or more with any tick depending of the symbol trade and the trading session.
You are correct, for low volatility period where the last tick is say 5 minutes ago, and the market is still active. But that is not really a draw back because who wants to trade on a old tick...🧐.