SMA(20)[30] - get the SMA(20) 30 bars ago.
Consider the following code.
namespace NinjaTrader.NinjaScript.Indicators { public class IndicatorISeriesTest : Indicator { protected override void OnStateChange() { switch(State) { case State.SetDefaults: Description = @"Testing the Indicators ISeries implementation"; Name = "IndicatorISeriesTest"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; BarsRequiredToPlot = 20; break; case State.DataLoaded: indicator = Range(); //Indicator picked here doesn't matter) break; } } Range indicator; protected override void OnBarUpdate() { Print(string.Format("indicator[0] = {0}, indicator.GetValueAt(CurrentBar) = {1}, indicator.Value.GetValueAt(CurrentBar) = {2}, indicator.Close.GetValueAt(CurrentBar) = {3}", indicator[0], indicator.GetValueAt(CurrentBar), indicator.Value.GetValueAt(CurrentBar), indicator.Close.GetValueAt(CurrentBar))); // indicator[0] == indicator.Value[0] but // indicator.GetValueAt(CurrentBar) != indicator.Value.GetValueAt(CurrentBar) // indicator.GetValueAt(CurrentBar) == indicator.Close.GetValueAt(CurrentBar) } } }
There is definitely an inconsistency in terms of how an indicator implements ISeries<double>
It returns indicator.Value for the [] operator but it returns indcator.Close when you call GetValueAt.
Why the inconsistency?
Comment