I have an indicator that shows the simple moving average 8 of the chart data and the simple moving average 8 of daily data. To do so, I import in my code the daily close and display my indicator on (for example) a five minuts chart. However, when I compare the SMA 8 daily on a daily chart and my SMA 8 daily on a 5 minuts chart, I don't have the same result (and can't figure out why). Can anyone help ? Thanks a lot !
namespace NinjaTrader.NinjaScript.Indicators { public class XXXIndicator : Indicator { double Moyenne1; double Moyenne2; private Series<double> CloseJour; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "XXXIndicator"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.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; AddPlot(Brushes.Yellow, "Plot1"); AddPlot(Brushes.Yellow, "Plot2"); AddPlot(Brushes.Yellow, "Plot3"); AddPlot(Brushes.Yellow, "Plot4"); CloseJour = new Series<double>(this, MaximumBarsLookBack.Infinite); } else if (State == State.Configure) { AddDataSeries(BarsPeriodType.Day, 1); } } protected override void OnBarUpdate() { if (CurrentBar<15 || CurrentBars[1]<15 ) return; CloseJour[0] = Closes[1][0]; Moyenne1 = SMA(Closes[0], 8)[0]; Moyenne2 = SMA(CloseJour, 8)[0]; Values[0][0] = Moyenne1; Values[1][0] = Moyenne2; } } }
Comment