Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reading parameter values

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

    Reading parameter values

    Hi,

    I need to read the parameter settings of the running strategy from within
    the script in a way that can be used in a general sub function / method.
    Therefore directly adressing the variables doesn't work.

    From within the strategy I tried the following but it didn't work:

    this.Parameters[index].Value.ToString()

    using

    this.Parameters[index].Name

    gives at least the name of the parameter(s).

    What must be used here to get the values?

    Thanks in advance, Stephan

    #2
    Stephan123, are the general subfunctions/methods in the same strategy file? Can you please clarify exactly what you're trying to do here?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hallo,

      the subfunction is called within OnTermination() of the strategy which I want to get the parameter values from.

      It looks like this:

      -Calling the subfuntion:

      PerformanceToFile(@"path",Performance);

      The function itself is defined within userdefined methods:

      public void PerformanceToFile(string path, SystemPerformance Performance)
      {
      //Here I need to read the set parameter values into some array.
      }

      All I need to know is how to access the parameter values in a general way
      that works for every strategy where this subfunction is called from.

      Comment


        #4
        Stephan123, I will have someone get back to you tomorrow.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Originally posted by Stephan123 View Post
          Hallo,

          the subfunction is called within OnTermination() of the strategy which I want to get the parameter values from.

          It looks like this:

          -Calling the subfuntion:

          PerformanceToFile(@"path",Performance);

          The function itself is defined within userdefined methods:

          public void PerformanceToFile(string path, SystemPerformance Performance)
          {
          //Here I need to read the set parameter values into some array.
          }

          All I need to know is how to access the parameter values in a general way
          that works for every strategy where this subfunction is called from.
          You simply call the parameter values by using their public exposed name.

          Comment


            #6
            Originally posted by koganam View Post
            You simply call the parameter values by using their public exposed name.
            Due to the above mentioned reasons I can't do it like
            name_of_thestrategy.name_of_the_public_property

            This is not a general solution which is applicable to any strategy.
            I look for something like
            int i = this.parameters.Count
            value = this.parameters[0 to i-1].value

            Comment


              #7
              Originally posted by Stephan123 View Post
              Due to the above mentioned reasons I can't do it like
              name_of_thestrategy.name_of_the_public_property

              This is not a general solution which is applicable to any strategy.
              I look for something like
              int i = this.parameters.Count
              value = this.parameters[0 to i-1].value
              I guess that I am confused then.

              What parameter values are you trying to read and access? Those of the strategy?
              Are you trying to read these values using the function in UserDefinedMethods.cs?

              Comment


                #8
                Originally posted by koganam View Post
                I guess that I am confused then.

                What parameter values are you trying to read and access? Those of the strategy?
                Are you trying to read these values using the function in UserDefinedMethods.cs?
                Both questions: yes
                The function in UserDefinedMethods must be applicable to every strategy
                without changing the code within the function.

                Comment


                  #9
                  Originally posted by Stephan123 View Post
                  Both questions: yes
                  The function in UserDefinedMethods must be applicable to every strategy
                  without changing the code within the function.
                  In that case, your situation is that you have a Class that is calling a function from another Class/Partial Class. The called function will not be able to have within its body the parameters of the calling class, as those are unknown to the function before it is called, so they cannot be in it.

                  Moreover, the parameters of the strategy are not a collection, so you are not going to be able to access those parameters in the manner that you seem to be describing.

                  However, as you can pass any parameter to the function if you choose to define it as such, one method is to define your function to take an ArrayList as one of its parameters. In that case, when you call it, you will pass it an ArrayList declared in your strategy. In the body of the function, you can then manipulate your ArrayList as you see fit. You could for example, populate the ArrayList with all the parameters, then access those parameters from the ArrayList, either within the function, or outside it, anywhere within the scope of the ArrayList declaration.

                  Comment


                    #10
                    Originally posted by koganam View Post
                    In that case, your situation is that you have a Class that is calling a function from another Class/Partial Class. The called function will not be able to have within its body the parameters of the calling class, as those are unknown to the function before it is called, so they cannot be in it.
                    The calling class is the particular strategy.
                    The called function is defined within partial class Strategy.
                    When I use the expression this. within the function
                    I get the reference to the strategy class from where the function is called.
                    Therefor I should be able to access any strategy properties.

                    As mentioned above it already works for the parameter names using this.Parameters[index].Name

                    Just the values don't work yet.
                    Of course I could directly pass the parameters as inputs to the function.
                    But I'd rather avoid it since it means addition al individual coding within every strategy.

                    Comment


                      #11
                      Originally posted by Stephan123 View Post
                      The calling class is the particular strategy.
                      The called function is defined within partial class Strategy.
                      When I use the expression this. within the function
                      I get the reference to the strategy class from where the function is called.
                      Therefor I should be able to access any strategy properties.

                      As mentioned above it already works for the parameter names using this.Parameters[index].Name

                      Just the values don't work yet.
                      Of course I could directly pass the parameters as inputs to the function.
                      But I'd rather avoid it since it means addition al individual coding within every strategy.
                      The called function cannot know from where it will be called. Therefore, it cannot possibly access directly anything that belongs to the calling class.
                      Last edited by koganam; 11-22-2011, 09:35 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      647 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X