I applied the 10.2 indicators, via the template, to a chart. I noticed, though, that other than the latest week, the histograms didn't reset. See the top histogram in the attachment.
Underneath that is the working one, after I tinkered with the code.
Has anyone else encountered this problem?
I'm not sure if I'm barking up the wrong tree or not.
I think the issue might be to do with the server time on the broker. I notice the code waits for a "day of week" equal to 0. My demo broker (FxPro) doesn't every have one - the day of the week ranges from 1 to 5. So as the code works backwards in time, the "wo" (weekly open" variable never gets changed from the first one it processes, which is the most recent one.
The fix was, rather than look for a day-of-week of 0, instead to find when we were at the bar where the day of the week of the *next* bar back in time was higher than the current day of week. That can only happen on the first bar of the week, which is where we want to calculate the new weekly open. Code looks like this:
Code: Select all
if(TimeDayOfWeek(iTime(NULL,0,i)) < TimeDayOfWeek(iTime(NULL,0,i+1))) j++;
Is this the right change to make? Should it then be pushed into the proper release? Without this or something like it, it appears the indicators don't work with some brokers.
Apologies for making this a bit Code-y, but I wanted 10.2 people to see it more than I wanted coders to see it.