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

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(1value); }
            }
            
    #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(1value); }
            }
            
    #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 RideMe, 04-07-2024, 04:54 PM
              6 responses
              31 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by tkaboris, Today, 05:13 PM
              0 responses
              2 views
              0 likes
              Last Post tkaboris  
              Started by GussJ, 03-04-2020, 03:11 PM
              16 responses
              3,281 views
              0 likes
              Last Post Leafcutter  
              Started by WHICKED, Today, 12:45 PM
              2 responses
              19 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by Tim-c, Today, 02:10 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X