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

Referencing an Indicator that has an enum input

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

    Referencing an Indicator that has an enum input

    I created an indicator that has one input variable, which is an enum as I wanted the user to select from a list. It works great. I also exposed certain values, for example:
    Code:
            [Browsable(false)]    
            [XmlIgnore()]        
            public DataSeries HIST
            {
                get { Update(); return Values[2]; }
            }
    Now I am writing another indicator in which I wish to use the first indicator. Yet when I wrote
    Code:
    DataSeries HistValues = IndName(eValue).HIST;
    I get an error = The name 'eValue' does not exist in the current context.

    Code:
    DataSeries HistValues = Indicator(eName.eValue).HIST;
    resulted in the error = An object refernce is required for the nonstatic field, method, or property 'NinjatraderIndicator.Indicator.IndName[eName]'

    The enum is public in the original indicator file but outside the namespace NinjaTrader.Indicator as I thought that would make it available to all.

    How do I use my indicator?

    #2
    OK, I added new
    Code:
    DataSeries HistValues = new Indicator(eName.eValue).HIST;
    and now the error = No overload for method 'IndName' takes 1 arguments.

    There is only 1 input variable under parameters -- none of the others are required for code usage (they affect display appearance only).
    What does it expect and how to I fix it?

    Comment


      #3
      Lost Trader,

      You can't create DataSeries like that. Please see this documentation on how to use DataSeries objects: http://www.ninjatrader-support.com/H...taSeriesObject
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        You are missing the point, Josh. The same error occurs when trying to access the int exposed variable:
        Code:
        private int testJosh = new ERG(ERGType.Trading).PrimeState;
        error = No overload for method 'ERG' takes 1 arguments.

        Comment


          #5
          If ERG is an indicator, you have to fill in a value for all public properties (I guess). In your case, there seem to exist more than just one.

          Regards
          Ralph

          Comment


            #6
            Doesn't make sense, Ralph. I've checked the "do not change" section of NT code and all the routines have this expression
            Code:
            public ERG ERG(ERGType type)
            No other input should be required.

            Comment


              #7
              Lost Trader,

              You are using techniques that we do not support. You are welcome to try, but we cannot assist you with unsupported techniques. If you want to access a value, use [] indexing to get the value.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Josh, exposing variables IS supported. In fact I believe it was YOU who told me to access an exposed variable, write the expression like this
                Code:
                [B]double indVal = IndicatorName().exposedVariable;[/B]
                Fine. But it doesn't WORK. Are you now going to claim NT doesn't support exposed variables if the indicator requires an input?

                Comment


                  #9
                  Originally posted by Lost Trader View Post
                  Doesn't make sense, Ralph. I've checked the "do not change" section of NT code and all the routines have this expression
                  Code:
                  public ERG ERG(ERGType type)
                  No other input should be required.
                  I agree with you.

                  If the compiler claims an illegal signature, there must be a reason? I am still confused about the new-statement in your example. Maybe because of that the compiler considers ERG(ERGType type) to be the class's constructor, wich doesn't exist with a single parameter?

                  Regards
                  Ralph

                  Comment


                    #10
                    Well, Ralph, if I remove the new and
                    Code:
                    private int testJosh = ERG(ERGType.Trading).PrimeState;
                    it is back to the error = An object reference is required for the nonstatic field, method, or property 'NinjatraderIndicator.Indicator.ERG[ERGType]'

                    I would prefer this version to work, for sure.

                    Comment


                      #11
                      Yes, funny error message. Could you try the more expicit version, even if it should work as you describe?

                      Code:
                      private int testJosh = base.ERG(ERGType.Trading).PrimeState;
                      Does your custom-indicator inherit from Indicator()?

                      Regards
                      Ralph

                      Comment


                        #12
                        Well it is different. Error = Keyword 'base' not available in the current context

                        Don't all indicators created in NT inherit ?

                        Comment


                          #13
                          Originally posted by Lost Trader View Post
                          Don't all indicators created in NT inherit ?
                          Not automatically, you have to declare it:

                          Code:
                          public class ERG : Indicator
                          {
                          }
                          Regards
                          Ralph

                          Comment


                            #14
                            Actually this is automatic when created with NT.... (and yes it is there)
                            Code:
                            public class ERG : Indicator
                            I would have never known to add it, but I checked and it is there.
                            I'd love more suggestions - I need a solution.

                            Comment


                              #15
                              My impression about the error message is that the compiler recognises method ERG() in baseclass Indicator() correctly, but in your code it suspects a static application (not bound to a class instance).

                              Where did you place ERG(...) in your code? Is it OnBarUpdate?
                              Do you use own namespaces?
                              Would this code compile: private ERG testJosh = ERG(ERGType.Trading);

                              Regards
                              Ralph

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DayTradingDEMON, Today, 09:28 AM
                              4 responses
                              21 views
                              0 likes
                              Last Post DayTradingDEMON  
                              Started by geddyisodin, Yesterday, 05:20 AM
                              9 responses
                              50 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by George21, Today, 10:07 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by Stanfillirenfro, Today, 07:23 AM
                              9 responses
                              24 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by navyguy06, Today, 09:28 AM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X