Indicator\MyCustomIndicator.cs The parameter name 'period' is a duplicate
I actually followed the tutorial exactly for Volume SMA without substituting ATR and EMA and got the same errors. Notice that the NinjaScript file its calling is "MyCustomIndicator" instead of "ATREMA". Could the problem be related to this? Aside from that, I'm stumped because I'm still very new at this. Here is my code -
#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 // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// ATR with EMA plotted /// </summary> [Description("ATR with EMA plotted")] public class ATREMA : Indicator { #region Variables // Wizard generated variables private int period = 8; // Default setting for Period // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0")); CalculateOnBarClose = true; Overlay = false; PriceTypeSupported = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Calculate the ATR average double average = EMA(VOL(), Period)[0]; // Set the calculated value to the plot Plot0.Set(average); } #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 Plot0 { get { return Values[0]; } } [Description("Number of Periods")] [Category("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { public partial class Indicator : IndicatorBase { private ATREMA[] cacheATREMA = null; private static ATREMA checkATREMA = new ATREMA(); /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> public ATREMA ATREMA(int period) { return ATREMA(Input, period); } /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> public ATREMA ATREMA(Data.IDataSeries input, int period) { checkATREMA.Period = period; period = checkATREMA.Period; if (cacheATREMA != null) for (int idx = 0; idx < cacheATREMA.Length; idx++) if (cacheATREMA[idx].Period == period && cacheATREMA[idx].EqualsInput(input)) return cacheATREMA[idx]; ATREMA indicator = new ATREMA(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; indicator.Input = input; indicator.Period = period; indicator.SetUp(); ATREMA[] tmp = new ATREMA[cacheATREMA == null ? 1 : cacheATREMA.Length + 1]; if (cacheATREMA != null) cacheATREMA.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheATREMA = tmp; Indicators.Add(indicator); return indicator; } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader.MarketAnalyzer { public partial class Column : ColumnBase { /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.ATREMA ATREMA(int period) { return _indicator.ATREMA(Input, period); } /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> public Indicator.ATREMA ATREMA(Data.IDataSeries input, int period) { return _indicator.ATREMA(input, period); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.ATREMA ATREMA(int period) { return _indicator.ATREMA(Input, period); } /// <summary> /// ATR with EMA plotted /// </summary> /// <returns></returns> public Indicator.ATREMA ATREMA(Data.IDataSeries input, int period) { if (InInitialize && input == null) throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); return _indicator.ATREMA(input, period); } } } #endregion
It is giving me the error in lines 140 and up, so in the portion that NinjaScript generates itself. Any help is greatly appreciated.
Comment