#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { public class SMATest : Indicator { #region Variables private int period = 2; private DataSeries test; #endregion protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "SMAT")); test = new DataSeries(this); CalculateOnBarClose = true; Overlay = true; PriceTypeSupported = false; } protected override void OnBarUpdate() { test.Set(High[0]); if(CurrentBar==0) return; test.Set(1, Close[1]); Print("test[1]: " + test[1].ToString() + " test[0]: " + test[0].ToString() + " SMA(test, 2)[0]: " + SMA(test, 2)[0].ToString()); } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries SMAT { get { return Values[0]; } } [Description("")] [Category("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } #endregion } }
test[1]: 916.5 test[0]: 916.75 SMA(test, 2)[0]: 3264.625
test[1]: 916.5 test[0]: 916.75 SMA(test, 2)[0]: 3264.75
test[1]: 916.5 test[0]: 916.5 SMA(test, 2)[0]: 3264.75
test[1]: 916.5 test[0]: 916.5 SMA(test, 2)[0]: 3264.75
there are 2 last values printed and SMA of those 2 values.
I expect totally different printout from SMA.
Any ideas?
thanks
Comment