Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Kaufman Efficiency Coding Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Kaufman Efficiency Coding Error

    This will probally be a 5 second fix for someone here but I have been trying to clear the following error all morning without luck

    "CS1513" "} EXPECTED". Line 186 and 185
    Ive placed the needed character where its supposed to be but the error wont clear. Any help is appreciated


    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class KaufmanEfficiency : Indicator
    {
    private Momentum MOM;
    private SMA TRIMA;
    private Series<double> Diff;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "KaufmanEfficiency";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = false;
    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;
    smoothingPeriod = 14;
    period = 10;
    AddPlot(Brushes.CornflowerBlue, "KaufEff");
    AddPlot(Brushes.Red, "Signal");
    AddLine(Brushes.Orange, 1, "ChopLine");
    }
    else if (State == State.Cnfigure)
    {
    Diff = new Series<double>(this);
    TRIMA = SMA(SMA(Input,period+1),period+1);
    MOM = Momentum(Input,1);
    }
    }

    protected override void OnBarUpdate()
    {

    if (CurrentBar < period)
    return;

    Diff.Set(Math.Abs(MOM[0]));
    double ratio = 0;
    if (CurrentBar > 2 * period)
    {
    double signal = Math.Abs(Input[0] - TRIMA[0]);
    double noise = (SUM(Diff, period))[0];
    if (noise != 0)
    ratio = 100 * (signal / noise);
    }
    EfficiencyRatio =(ratio);
    Average =(EMA(EfficiencyRatio, smoothingPeriod)[0]);
    ChopLine =(100/Math.Sqrt(period));
    }

    #region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="SmoothingPeriod", Order=1, GroupName="Parameters")]
    public int smoothingPeriod
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Period", Order=2, GroupName="Parameters")]
    public int period
    { get; set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> KaufEff
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> Signal
    {
    get { return Values[1]; }
    }
    [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 EfficiencyRatio
    {
    get { return Values[0]; }
    }

    [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 Average
    {
    get { return Values[1]; }
    }

    [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 ChopLine
    {
    get { return Values[2]; }
    #endregion

    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private KaufmanEfficiency[] cacheKaufmanEfficiency;
    public KaufmanEfficiency KaufmanEfficiency(int smoothingPeriod, int period)
    {
    return KaufmanEfficiency(Input, smoothingPeriod, period);
    }

    public KaufmanEfficiency KaufmanEfficiency(ISeries<double> input, int smoothingPeriod, int period)
    {
    if (cacheKaufmanEfficiency != null)
    for (int idx = 0; idx < cacheKaufmanEfficiency.Length; idx++)
    if (cacheKaufmanEfficiency[idx] != null && cacheKaufmanEfficiency[idx].smoothingPeriod == smoothingPeriod && cacheKaufmanEfficiency[idx].period == period && cacheKaufmanEfficiency[idx].EqualsInput(input))
    return cacheKaufmanEfficiency[idx];
    return CacheIndicator<KaufmanEfficiency>(new KaufmanEfficiency(){ smoothingPeriod = smoothingPeriod, period = period }, input, ref cacheKaufmanEfficiency);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.KaufmanEfficiency KaufmanEfficiency(int smoothingPeriod, int period)
    {
    return indicator.KaufmanEfficiency(Input, smoothingPeriod, period);
    }

    public Indicators.KaufmanEfficiency KaufmanEfficiency(ISeries<double> input , int smoothingPeriod, int period)
    {
    return indicator.KaufmanEfficiency(input, smoothingPeriod, period);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.KaufmanEfficiency KaufmanEfficiency(int smoothingPeriod, int period)
    {
    return indicator.KaufmanEfficiency(Input, smoothingPeriod, period);
    }

    public Indicators.KaufmanEfficiency KaufmanEfficiency(ISeries<double> input , int smoothingPeriod, int period)
    {
    return indicator.KaufmanEfficiency(input, smoothingPeriod, period);
    }
    }
    }

    #endregion
    Last edited by Teebone21; 11-12-2020, 04:37 AM.

    #2
    Error fixed

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    548 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X