Values[1][0]=EMA(Values[0],MAPeriod);
// entire code snippet
CustomATR.cs Cannot implicitly convert type 'NinjaTrader.NinjaScript.Indicators.EMA' to 'double' CS0029 80 18
{ AddPlot(Brushes.DarkCyan, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNa meATR); AddPlot(Brushes.Yellow, "ATR MA"); } } protected override void OnBarUpdate() { double high0 = High[0]; double low0 = Low[0]; if (CurrentBar == 0) Value[0] = high0 - low0; else { double close1 = Close[1]; double trueRange = Math.Max(Math.Abs(low0 - close1), Math.Max(high0 - low0, Math.Abs(high0 - close1))); Values[0][0] = ((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + trueRange) / Math.Min(CurrentBar + 1, Period); } if(CurrentBar>MAPeriod) { Values[1][0]=EMA(Values[0],MAPeriod); } } Properties [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)] public int Period { get; set; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "MA Period", GroupName = "NinjaScriptParameters", Order = 1)] public int MAPeriod { get; set; }
Comment