Eg. I load a 233 Tick chart for CL ##-## with 15 days data ending on Jan 15 2016. The bar index for Bars.GetBar(new DateTime(2016,01,11,9,15,20)) is 7487
Time[7487] = 1/7/2016 10:50:03 PM, and any bar data or indicator values are also wrong.
No doubt I'm missing something obvious.. do I need to offset the value from GetBar somehow?
To test, I have an indicator with just the following code in a mouse up event, and no other indicators in the chart.
var barTime = new DateTime(2016,1,11,9,15,20);
var barIndex = Bars.GetBar(barTime);
Print (string.Format("Time: {0}, barIndex: {1}, Time[barIndex]: {2}",
barTime, barIndex, Time[barIndex]));
Time: 1/11/2016 9:15:20 AM, barIndex: 7487, Time[barIndex]: 1/7/2016 10:50:03 PM
thanks.

That statement returns the bar's index, not the number of bars ago. To get the number of bars ago, you would have to deduct the index from CurrentBar. In other words, Bars.GetBar returns the index of the bar; Time[] returns the value of a number of bars ago from the CurrentBar.
Comment