Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Read strategy parameters

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

    Read strategy parameters

    Hi,

    how does one obtain the values of
    <mystrategy>.Parameters[index] ?
    When I try it with Parameters[index].Value it's empty.
    Parameters[index].Name works though.

    What's wrong here?

    #2
    Hi Stephan123, accesing the running strategy instance parameters is unfortunately not supported in NinjaScript.

    Comment


      #3
      if you want to edit the running strategy parameters, then my tool might be of help:

      Discover top crypto trading apps like Binance for secure, low-fee trading. Access crypto, forex, and more with real-time tools. Avoid scams, start small, and grow profits.



      best regards
      Andreas

      Comment


        #4
        Is accessing the running strategy instance parameters also not possible
        within OnTermination()?

        I only want to read and print them to a file. No editing is neccessary.

        Comment


          #5
          i think a simple this.ToString() would be enough for your needs, else you could get the propertyinfo from the Type.

          Comment


            #6
            Originally posted by bukkan View Post
            i think a simple this.ToString() would be enough for your needs, else you could get the propertyinfo from the Type.
            I already tried this.ToString() .
            The problem: parameter values are separeted by commas.
            If the parameters are double values they have commas as well and there is no way to
            recognice the separation of the parameters.

            using propertyinfo gives me all properties of the strategy class, if applied to the type of the strategy class. I didn't find a way to filter for
            the strategy parameters only.

            Comment


              #7
              Originally posted by Stephan123 View Post
              I already tried this.ToString() .
              The problem: parameter values are separeted by commas.
              If the parameters are double values they have commas as well and there is no way to
              recognice the separation of the parameters.

              using propertyinfo gives me all properties of the strategy class, if applied to the type of the strategy class. I didn't find a way to filter for
              the strategy parameters only.
              In that case, it looks like you will need to use the CultureInfo and IFormatProvider in the ToString() method.

              ref: http://msdn.microsoft.com/en-us/library/shxtf045.aspx

              Comment


                #8
                I tried:

                Print(this.ToString(CultureInfo.CreateSpecificCult ure("en-GB")));

                It gives error CS0103.
                it doesn't know CultureInfo in this context.
                How should it be?

                Comment


                  #9
                  You can filter the strategy properties for the gridcategory attribute
                  Andreas
                  Discover top crypto trading apps like Binance for secure, low-fee trading. Access crypto, forex, and more with real-time tools. Avoid scams, start small, and grow profits.


                  This is what i do in my ninjatinymobiletrader

                  Comment


                    #10
                    Originally posted by Stephan123 View Post
                    I tried:

                    Print(this.ToString(CultureInfo.CreateSpecificCult ure("en-GB")));

                    It gives error CS0103.
                    it doesn't know CultureInfo in this context.
                    How should it be?
                    "this" is the class itself. CultureInfo is used on numbers.

                    Comment


                      #11
                      Originally posted by Stephan123 View Post
                      I already tried this.ToString() .
                      The problem: parameter values are separeted by commas.
                      If the parameters are double values they have commas as well and there is no way to
                      recognice the separation of the parameters.

                      using propertyinfo gives me all properties of the strategy class, if applied to the type of the strategy class. I didn't find a way to filter for
                      the strategy parameters only.
                      yes split the same, use regex etc etc.

                      if you need to do more then you have to use the propertyinfo. as Andreas rightly said, filter the values as per required.

                      Comment


                        #12
                        Still two questions:

                        1) When using this.ToString() I get a string such as
                        mystrategy(2,5,2,4,true)

                        Since the comma is both decimation and seperating sign
                        parameter values can't be directly obtained from the string.
                        Is there a solution to that?

                        2) I would like to define the strategy itself as an input parameter of a function.
                        I tried it with

                        testfunction(this) for calling the function within the strategy
                        and
                        public void testfuntion(object myclass)
                        for defining the function within UserDefinedMethods.

                        Now I wonder how to extract any information from the object myclass,
                        such as myclass.performance or typeof(myclass).
                        How must this be coded?

                        Thanks in advance, Stephan

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        652 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        370 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        577 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X