For example:
I am trying find the start and end bars for the session. The instrument i am using is ES. The first series is 2500 Volume bars, the secondary series is 1 Tick bars. I have a rectangle drawn on the start and end bars for the day. I use the following code:
leftBarsAgo = BarsArray[1].GetBar(Times[0][globalLine.StartBarsAgo]);
rightBarsAgo = BarsArray[1].GetBar(Times[0][globalLine.EndBarsAgo]);
since the getBar is arranged in the opposite direction of Times Dataseries I use the following:
rightBarsAgo = Times[1].Count - rightBarsAgo;
leftBarsAgo = Times[1].Count - leftBarsAgo;
Times[1][rightBarsAgo] is equal to 4/2/2014 1:14:59
Times[1][rightBarsAgo - 86] is still equal to 4/2/2014, so I am missing 86 ticks of data because it is not being aligned properly. I believe this is because ninjatrader is finding the first instance of 4/2/2014 1:14:59 and returning this bar. I guess this is not unexpected since the times are the same, but these bars are not aligned. The 2500V bar last bar is not returning the corresponding last tick. My question is, is GetBar optimized in anyway to efficiently find bars, or is it simply comparing each date and moving to the next bar?
Comment