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

Average of CCI Indicator

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

    Average of CCI Indicator

    I'm not a programmer so I'm trying to copy the NinjaScript tutorial for Indicator on Indicator except with an SMA on CCI instead of Vol. I'm using the Indicator Wizard.. I've used the code from the Strategy Wizard for the SMA of CCI. When I try to compile it I get three Errors: CS0018, CS1502 and CS1503. Here's the code

    protected override void OnBarUpdate()
    {

    //Calculate average of CCI
    double average = SMA(CCI(14), Period)[0];


    Plot0.Set(average);
    }

    If anyone can point out whatever obvious or subtle mistakes I'm making, I would be grateful.

    PJ

    #2
    Originally posted by pjwinner View Post
    I'm not a programmer so I'm trying to copy the NinjaScript tutorial for Indicator on Indicator except with an SMA on CCI instead of Vol. I'm using the Indicator Wizard.. I've used the code from the Strategy Wizard for the SMA of CCI. When I try to compile it I get three Errors: CS0018, CS1502 and CS1503. Here's the code

    protected override void OnBarUpdate()
    {

    //Calculate average of CCI
    double average = SMA(CCI(14), Period)[0];


    Plot0.Set(average);
    }

    If anyone can point out whatever obvious or subtle mistakes I'm making, I would be grateful.

    PJ
    You can not use the word "Period" there as it is not defined as a variable.. You need a variable or a #.

    double average = SMA(CCI(14), 12)[0];

    What you more than likely need is to add a variable for "Period" in your parameter list.
    (Where MyInput0 is declared in the indicator builder).

    If you edit the SMA, Period is defined as a parameter in the #region area

    #region Properties
    /// <summary>
    /// </summary>
    [Description("Numbers of bars used for calculations")]
    [GridCategory("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }
    #endregion

    Comment


      #3
      Changing the "Period" to a number worked! I'll try adding Period as a variable. Thanks so much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by FrancisMorro, Today, 03:24 AM
      0 responses
      1 view
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,769 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      10 views
      0 likes
      Last Post Max238
      by Max238
       
      Working...
      X