First off, in case it matters, I am using a 21-tick range bar on my chart. Volumetric range bar to be precise, but it acts the same on a plain 21-range.
So I decided to write a couple of functions (again, called in BarsInProgress==1 section) to tell me when its the last tick of a candle and when its the first.
I can tell if it's the last tick of the open range bar by checking that:
1. the (high - low) == 21 ticks
2. the (close == high || close == low)
So in this case, close refers to the 1-tick series close, which is the last price (that's what my chart is set to display).
Of course this will give false positives, because those two conditions can be satisfied any number of times if the price retraces before making the 22nd tick. But I only need the first one to trigger my action, so that is okay with me.
To tell if it's the first tick of a new bar, I merely need to check that the (high == low).
In those functions, I have to explicitly refer to the chart prices, so I use the second array index, like this:
private bool IsFirstCandleTick()
{
/// Must wait for one bar to close to establish range bar height - historical will do
if (!oneBarClosed) return false;
/// Called from tick series, so specify to use chart bars
return (Highs[0][0] == Lows[0][0]);
}
However, it does not seem to work. When I add logging, it seems that references to High, Low, Close are returning values for the first closed candle, not the open candle, which should be [0][0].
Can someone please explain what is going on and how I can reference the open chart candle?
I wrote this dumbed-down sample so you can run the attached code and check the log to see what it does.

Comment