Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inputs for indicators

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

    Inputs for indicators

    I have an indicator written the way I want it, it compiles fine and runs fine, but only as long as it contains this code which was generated when I first created the Indicator:

    PHP Code:
    #region Properties
            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    
            [Description("")]
            [GridCategory("Parameters")]
            public int MyInput0
            {
                get { return myInput0; }
                set { myInput0 = Math.Max(1, value); }
            }
            #endregion 
    
    I have removed all other mentions of 'myInput0" in my code, but if I remove this part, it won't compile. Is it because every indicator MUST have at least 1 input, or is there some way to get rid of this?

    #2
    Originally posted by Radical View Post
    I have an indicator written the way I want it, it compiles fine and runs fine, but only as long as it contains this code which was generated when I first created the Indicator:

    PHP Code:
    #region Properties
            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    
            [Description("")]
            [GridCategory("Parameters")]
            public int MyInput0
            {
                get { return myInput0; }
                set { myInput0 = Math.Max(1, value); }
            }
            #endregion 
    
    I have removed all other mentions of 'myInput0" in my code, but if I remove this part, it won't compile. Is it because every indicator MUST have at least 1 input, or is there some way to get rid of this?
    What is the error message? Unfortunately, this code on its own does not mean much in the scheme of things. You can have indicators with no user inputs. In fact, many of the shipping indicators have no inputs (BarTimer, for example).

    Comment


      #3
      Sorry, I forgot to post what the errors are, there are 2:

      Error: "Type expected"
      Error: "Invalid token '}' in class, struct, or interface member declaration

      To put it into context:

      PHP Code:
      namespace NinjaTrader.Indicator
      {
          [Description("")]
          public class myindicator : Indicator
          {
              
              protected override void Initialize()
              {
              }
      
              
              protected override void OnStartUp()
              {
              }
                              
                          
              protected override void OnBarUpdate()
              {
              }
              
      
              #region Properties
              [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
              [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      
              [Description("")]
              [GridCategory("Parameters")]
              // THE myInput0 CODE WOULD START ON THIS LINE
              #endregion
          }       <---------------THIS is the line that the errors refer to
      } 
      

      Comment


        #4
        You will have to check all your bracketing, to make sure that all open "{" have a corresponding "}". Do not just delete the one that appears to be the extra. The compiler is not very smart about pairing braces, so the indicated brace just means that there is an extra one somewhere in the code. It could be the indicated one, but then again it might not.

        Comment


          #5
          That was the first thing I looked for, but I'm positive there aren't any extra brackets anywhere in the indicator. And this doesn't just happen in this indicator--if I go to Tools>New Ninjascript>Indicator>Generate Code (in other words a blank, new indicator) and delete the 'myInput0' bit of code that I'm talking about, I get the same error.

          Comment


            #6
            Hi Radical,

            It doesn't look like you are using the properties region at all, so you can delete everything below. If you want to keep as placeholder in case you add inputs, can leave the lines starting with #.

            Code:
            #region Properties
                    [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                    [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            
                    [Description("")]
                    [GridCategory("Parameters")]
                    // THE myInput0 CODE WOULD START ON THIS LINE
                    #endregion
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks, that fixed it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              566 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              547 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              548 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X