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 fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,404 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      95 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      8 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      159 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X