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 bill2023, Yesterday, 08:51 AM
      7 responses
      43 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      25 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Working...
      X