I'm interested to understand some of the nuances and best practices around aligning single-tick bars with non-tick bars (range bars in this case) where the range bars are the primary series and the tick bars are the secondary series for the same instrument.
I'm trying to understand how the OnBarUpdate event can fire in this scenario. I do understand there's no guarantee of the order in which the event will fire for any given tick - it might fire for the secondary series first or it might fire for the primary series first.
However, I don't know for certain if they can both effectively be executing at the same time on different threads. Does anyone know the answer to that?
Meanwhile, what I'm trying to do is I was looking to track the volume for each tick in each range separately. What I tried was using the FirstTickOfBar and BarsInProgress to try to reinitiatlize my volume tracking variables with each new bar. But I quickly saw that for the eight tick range bars I was using, sometimes I had captured eight ticks worth of data for a bar, other times 7, other times 9, and sometimes 6. So that didn't work.
My thought is to try to use some kind of synchronization variable, but that approach would have to be thread safe. For a given tick, the OnBarUpdate event for the one-tick bar and for the range bar could conceivable try to check and modify its value at the same time.
Thank you in advance for your ideas. If anyone is aware of a good code sample that would be great as well.
Regards,
Gordon
Comment