Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      597 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      555 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X