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

Controlling Parameter Sequencing

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

    Controlling Parameter Sequencing

    In 6.5, have there been any enhancements in the abilty to sequence the parameter items? This post had some suggestions (http://www.ninjatrader-support.com/v...ead.php?t=1741) but I find them lacking for strategies with a large number of parameters.

    I've used the following approach without issue to force parameters into a more useful sequence than the default alpha sort:

    Code:
    private int     pSmaPeriod   = 10;  // 01
    private int     pVolPeriod   = 21;  // 02
    private double  pAtrMult     = 1.5;  // 03 
    . . .
    private string  pAtmTemplate = "myATM";  // 18
    . . .
    
    [Description("SmaPeriod")]
    [Category("Parameters")]
    public int p01_SmaPeriod
    {
         get { return pSmaPeriod; }
         set { pSmaPeriod = Math.Max(0, value); }
    }
    [Description("VolPeriod")]
    [Category("Parameters")]
    public int p02_VolPeriod
    {
         get { return pVolPeriod; }
         set { pVolPeriod = Math.Max(0, value); }
    }
    [Description("AtrMult")]
    [Category("Parameters")]
    public double p03_AtrMult 
    {
         get { return pAtrMult; }
         set { pAtrMult = Math.Max(0, value); }
    }
    . . .
    [Description("AtmTemplate")]
    [Category("Parameters")]
    public string p18_AtmTemplate 
    {
         get { return pAtmTemplate; }
         set { pAtmTemplate = value; }
    }
    I find this approach useful in that:
    • I control the sequencing of parameters,
    • parameters can be identified using meaningful names vs awkward variations to control sorting.
    • I know immediately that a class variable prefaced with a "p" is of local scope and the same variable name prefaced with "pNN_" to be of public scope,
    • Adding new variables is a simple cut and paste operation and avoids managing the upper/lower case versions of the public/private scope variables,
    • Referring to a parameter item by number can have its advantages when working with a long list of parameters,
    • Of course, inserting a new variable can be a real hassle since the sequence number is hardcoded in the public variable name but it's a necessary evil if parameter sequencing is desired.


    Ideally, it would be nice to control the sequencing through other means. Comments and alternative ideas welcome.

    Regards,

    Whitmark
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    Hi whitmark,

    You can sort your parameters by separating them into different section groupings. This can be done by changing the category line.

    For instance you can do something like this:
    Code:
    [Category("Variables")]
    You can also change the way the parameter names are displayed with a line like this. Although this doesn't reorder parameters it does allow for a more friendly looking name to be displayed for the parameter.
    Code:
    [Gui.Design.DisplayName("Volume Period")]
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Gui.Design.DisplayName for Sequencing Parameters

      Thanks Josh,

      Yes, I have used these techiques too. It might be worth noting, if I am not mistaken, that the use of [Gui.Design.DisplayName("Volume Period")], for example, will drive the alpha sort of items in the indicator/strategy dialog box, but the sequence of the parameters listed following indicator/strategy name on the chart will be based on an alpha sort of the public variable name which could lead to differences.

      When you don't use [Gui.Design.DisplayName("Volume Period")], for example, the Gui.Design.DisplayName will take the name of the public "pNN_" variable and both will be sequenced in the same manner. Or the "pNN" could be used in the first part of the Gui.Design.DisplayName to ensure proper sequencing in both places. Your suggestions are useful and my workarounds are clearly function over "friendly" form.

      Regards,

      Whitmark
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        I have not tested, but I believe what you say is the way it would behave.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Whitmark, thanks for the idea...never thought of putting the "pNN_" in there!

          One good idea deserves another, you can get around this "hassle" of insertion by spacing out your sequence numbers (just like we did in the old programming days. Your initial parameter sequence can be divided by 5's or 10's as this:
          p100_VariableX
          p110_VariableA
          p120_VariableC

          This way you can insert "p106" at some later time without hassle.

          Originally posted by whitmark View Post
          • Of course, inserting a new variable can be a real hassle since the sequence number is hardcoded in the public variable name but it's a necessary evil if parameter sequencing is desired.

          Regards,

          Whitmark

          Comment


            #6
            Hey Guys,

            Sometimes when I change the category in a strategy (such as, change Parameters to "Variables"), the "Variables" section doesn't display.

            Has anyone else experienced this?

            Code:
                    [Description("Numbers of bars used for Stoch calculations")]
                    [Category("Variables")]
                    public int PeriodK
                    {
                        get { return iPeriodK; }
                        set { iPeriodK = Math.Max(1, value); }
                    }
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Originally posted by mrlogik View Post
              Hey Guys,

              Sometimes when I change the category in a strategy (such as, change Parameters to "Variables"), the "Variables" section doesn't display.

              Has anyone else experienced this?

              Code:
                      [Description("Numbers of bars used for Stoch calculations")]
                      [Category("Variables")]
                      public int PeriodK
                      {
                          get { return iPeriodK; }
                          set { iPeriodK = Math.Max(1, value); }
                      }
              The change from "Parameters" to "Other One" only work for Indicators not for Strategies, well at least this is my experience.

              Comment


                #8
                If I recall, I think Indicators have more flexibility here than Strategies, likely since Strategies require the parameters to be in a single collection for backtesting and optimization purposes.
                whitmark
                NinjaTrader Ecosystem Vendor - Whitmark Development

                Comment


                  #9
                  Yes, I know I've done it with indicators.

                  Thanks for the information guys!
                  mrlogik
                  NinjaTrader Ecosystem Vendor - Purelogik Trading

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RookieTrader, Today, 07:41 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by kujista, Today, 05:44 AM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by elderan, Yesterday, 08:03 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by samish18, Yesterday, 08:57 AM
                  8 responses
                  25 views
                  0 likes
                  Last Post samish18  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  3 responses
                  10 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Working...
                  X