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

Want to create a new constructor for an indicator

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

    Want to create a new constructor for an indicator

    I have an indicator which started off as a small prototype and now has 8 parameters.

    I would like to have a constructor for the indicator that takes all 8 parameters. How can I create or code this? I have looked at the generated code and it doesn't seem obvious, and the indicator wizard only allows me to specify 4 parameters.

    Thanks

    #2
    adamus, you can add user defined inputs with those instructions posted in the tips section -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      do you mean to imply that just adding the input parameters like the example you gave will actually add the parameters to the constructor for the indicator?

      I construct my indicator in my strategies like this:

      Code:
      FXCorrelator correlator = FXCorrelator();
      However I have 8 parameters which I wish to pass in so actually I want to do this:

      Code:
      FXCorrelator correlator = FXCorrelator(true, true, true, false, true, false, false, false);
      However this constructor for the indicator doesn't exist and I would like it to. Can you tell me how to set it up?

      Thanks
      Last edited by adamus; 09-08-2010, 08:37 AM.

      Comment


        #4
        Hello adamus,

        Yes, once you add the public inputs, the constructor will then reflect the new inputs.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          that's not what I'm seeing. In the tool tip that appears showing the possible completions, for my indicator I only have the zero parameter indicator, and the 1 parameters indicator taking the BarsArray data series.

          Is there any extra stuff that is needed to facilitate this? I stripped out all comments and #regions etc to get a better overview of my code.

          I

          Comment


            #6
            Did you touch any of the NinjaScript wizard generated code section (suggested to leave as is)?

            You can copy your script into a complete new indicator so this is regenerated then.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              No, I'm sure I didn't.

              But I'll try starting from scratch again to see if it works on a fresh indicator script file.

              What you are saying is that the wizard-generated code will be regenerated if I add another parameter?
              Last edited by adamus; 09-08-2010, 11:05 AM.

              Comment


                #8
                OK so it does generate a new constructor then - and the parameters are nicely sorted, alphabetically.

                So I'm not sure what I did wrong earlier, but I'm ok now.


                Thanks

                Comment


                  #9
                  Did this resolve itself? I'm having the same issue with my overloaded indicator constructor. When I added a new parameter the auto-generated code still did not produce a an overloaded constructor. (i.e. myIndicator(a,b,c,d) is not recognized). There is definitely something weird going on.

                  Here is the thread I created http://www.ninjatrader.com/support/f...338#post341338

                  Comment


                    #10
                    No, I haven't had any more issues with this.

                    As you said in the other thread, you need the region / endregion wrappers around the parameters - I found removing them mucks it up.

                    If you're still having issues, I'd recommend renaming the indicator (to anything just to get rid of your old code) and copying in your code into a new script file generated by the wizard. You just use the name you want for the indicator, and don't give it any parameters or anything in the wizard, just hit 'Generate' at the first opportunity.

                    HTH

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by sidlercom80, 10-28-2023, 08:49 AM
                    166 responses
                    2,234 views
                    0 likes
                    Last Post sidlercom80  
                    Started by thread, Yesterday, 11:58 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post thread
                    by thread
                     
                    Started by jclose, Yesterday, 09:37 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,414 views
                    0 likes
                    Last Post Traderontheroad  
                    Started by firefoxforum12, Yesterday, 08:53 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post firefoxforum12  
                    Working...
                    X