A reader of this blog proffered an excellent question on this indicator. I hope this post answers his question and I am always open to any input that might improve my coding!
Because I use BarNumber in my MODULUS calculation the different time frames that I keep track of may not align with the time frames on the chart; your 10-minute bar O, H, L, and C values may not align with the values I am storing in my 10-minute bar container. Take a look at this snapshot of a spreadsheet.
Here I print out a 5-minute bar of the ES.D. Because I use BarNumber in my Modulus calculation, I don’t get to a zero remainder until 9:50 in the 10, 15, and 20 minute time frames. At 9:50 I start building fresh 10, 15, 20 minute bars by resetting the O, H, L and C to those of the 5-minute bars. From there I keep track of the highest highs and lowest lows by extracting the data from the 5-minute bar. I always set the close of the different time frames to the current 5-minute bar’s close. Once the modulus for the different time frames reaches zero I close out the bar and start fresh again. The 25-minute bar didn’t reach zero until the 10:05 bar.
I will see if I can come up with some code that will sync with the data on the chart.