Sorry, here updating the code above.
the timegap between D1 bar open times, one before weekend, and one after market opening and start of new trading week, is actually 72 hours.
So the 47 hour above should be changed to 71 hours. much better.
Plus, the for loop in the first tick block, should be breaked if the most recent week start day is found.
so :
for(int d=7; d>0; d--) if(DTimes[d]-DTimes[d-1] > 71*3600) { WEEK_START_TIME = DTimes[d]; break; } // 71 hours time-gap found
and
if(current_D1_time - last_D1 > 71*3600) WEEK_START_TIME = current_D1_time;
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
This is my try to solve the problem of broker timezone differences.
I'm trying to find the Hour of Day, based on the real forex market timings, independent of any time settings (Client, Broker, or anything related to time zones and DST).
So hour Zero is exactly when the forex market gets open (which is based on NY time 8:00 AM) and hour 119 is the last hour market is open, and @ 119:59:59+1second market gets closed.
and I need it to work in backtest.
This method seemingly works when I test on charts of my broker, But it assumes that the timeseries and chart bars are formatted as such:
Have I assumed too much ? what else can I do to make sure this procedure doesn't return erroneous results?
I feel it's not robust enough for different situations, but don't know what checkups makes it less prone to failure.