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
Welcome.
here some Instructions on how to use the function:
Forum on trading, automated trading systems and testing trading strategies
How to find the Friday's market closing time?
Alain Verleyen, 2016.12.22 18:44
And even the code I used :
uint session=0;
while(SymbolInfoSessionQuote(_Symbol,FRIDAY,session,from,to))
{
printf("Quoting session %i start %02i:%02i to %02i:%02i",session,from/3600,(from%3600)/60,to/3600,(to%3600)/60);
session++;
}
session=0;
while(SymbolInfoSessionTrade(_Symbol,FRIDAY,session,from,to))
{
printf("Trading session %i start %02i:%02i to %02i:%02i",session,from/3600,(from%3600)/60,to/3600,(to%3600)/60);
session++;
}
A lot has already been asked and answered, please use the search engine before posting.
I don't get it. What issue about "the shift between market time on chart and session hours" ? There is no shift I am aware of.
I am using the code I posted above on production, on a bunch of brokers and there is no problem.
You are creating problems by yourself. The local time has nothing to do with all of that. The chart time, the server time, the session time (as reported by SymbolInfoSessionTrade) are all the same time. There is no problem.
I have no idea why you talk about Exchange sessions and calendar in this topic, but :
The chart/broker/server time is known, the London/New-York/Sydney are known, it's trivial to go from one to the other.
A calendar time is known, say GMT, it's not complicated to calculated it according to the GMT shift of the broker which is easy to calculate.
There is only one real difficulties it's when you need to place an event in history, because DST is at play and it's not possible to get DST by code, you need to know it broker by broker, server by server.
Sometimes the candle doesn't close when they said it would with SymbolInfoSessionTrade() .
During my backtesting I had a friday candle close at 18:47 but SymbolInfoSessionTrade() said 23:58 was the end of the session.
I only use server time TimeCurrent() in my code to get Datetime informations.
That's because there is no history data for sessions, the values you get with SymbolInfoSessionTrade() are the current ones, but the history data (OHLC or ticks) can have been recorded when the sessions were different.
If SymbolInfoSessionTrade() indicate an open market while it's actually closed as in your case, there is no problem as you will not have ticks.
If SymbolInfoSessionTrade() indicate a close market, then don't try to open trade even if there are ticks. If you try nonetheless, deal with it by processing the error.
TimeCurrent() doesn't say anything by itself.
Here is my function to solve the issue:
I implemented your code into my EA and it works great - thank you. This code is only for long positions and I am struggling to implement it for short positions as well, can you please help with the code for short position as well. Will be much appreciated.
From and to time that we get through SymbolInfoSessionTrade is based on server-time or GMT.?
Thanks
Code it correctly.
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 (2014)
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011)