Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Converting KAMA to operate on other than close

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

    Converting KAMA to operate on other than close

    I worked out all the changes and I am ready to compile except there is something wrong with the last line (see bottom of page) The error messages are:

    NinjaScript File Error Code Line Column Indicator\KAMACCI.cs Class member declaration expected.
    74 24 Indicator\KAMACCI.cs ] expected.
    74 31
    Could you look at it and tell me if you see anything wrong with it.
    Thanks,
    Burt O'Donald

    KAMACCI : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int period = 10; // Default setting for Period
    private int fast = 2; // Default setting for Fast
    private int slow = 30; // Default setting for Slow
    private int cCI_period = 6; // Default setting for CCI_period
    // User defined variables (add any user defined variables below)
    DataSeries diffSeries
    #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, "KAMA_CCI"));
    diffSeries = new DataSeries(this);
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    if ( CurrentBar > 0)
    {
    diffSeries.Set(Math.Abs(CCI(cCI_period)[0] - CCI(cCI_period) [1]));
    }
    if (CurrentBar < period)
    {
    Value.Set (CCI(cCI_period)[0]);
    return;
    }
    double fastCF = 2.0 / (double) (fast + 1);
    double slowCF = 2.0 / (double) (slow +1);

    double signal = Math.Abs (CCI(cCI_period)[0] - CCI(cCI_period) [period]);
    double noise = SUM(diffSeries, Period) [0];

    // Prevent devide by zero
    if (noise == 0)
    {
    Value.Set(Value[1]);
    return;
    }
    double smooth = Math.Pow ((signal / noise) * (fastCF - slowCF) + slowCF, 2);
    Value.Set(Value[1] + smooth * (CCI(cCI_period) [0] - Value[1]));
    }
    // plot below by replacing 'Close[0]' with your own formula.
    KAMA_CCI.Set(Value[0]);
    }

    #2
    Do you actually have a plot named KAMA_CCI in the Properties region?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Looks like mismatched braces to me (too many "}" characters), which would make your KAMA_CCI.Set statement outside of the OnBarUpdate method.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      5 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      5 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X