It has taken too many tokens to figure it out, so I figured I’ll post it here:
if (BarsInProgress == 1)
{
// some code
if (State == State.Historical & !Bars.IsTickReplay)
{
primaryBar = CurrentBars[0] + 1;
if (primaryBar >= BarsArray[0].Count) return; // trailing secondary tick past last primary bar
}
else
{
primaryBar = CurrentBars[0];
if (primaryBar < 0) return; // primary series not yet started
}
The reason why: historical primary bar index advances at the end of the bar (intra bar activity happens in secondary data series only). The symptom is that data from secondary bar series is attributed to previous primary bar, until State.Realtime.