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

Optimization not testing indicated input range

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

    Optimization not testing indicated input range

    I just added two Variables to my strategy (the values had previously be fixed in the code). They are "int" inputs for moving averages.

    After adding the "Variables" code and the "Parameters" descriptions the optimization will not run through the range of inputs for any of the integer variables in the strategy. It will do the iterations, but the variable does not change. If I set a minimum value in the "Parameters" description that is the value that shows up.

    The "double" variables optimize as before.

    Any suggestions?

    #2
    Originally posted by SteveH View Post
    I just added two Variables to my strategy (the values had previously be fixed in the code). They are "int" inputs for moving averages.

    After adding the "Variables" code and the "Parameters" descriptions the optimization will not run through the range of inputs for any of the integer variables in the strategy. It will do the iterations, but the variable does not change. If I set a minimum value in the "Parameters" description that is the value that shows up.

    The "double" variables optimize as before.

    Any suggestions?
    That your boundary condition is your optimal value is a testament that you may not have found the true optimal value. Change your range to make that value no longer the boundary value. I generally hate to make absolute statements. This is an absolute statement: there really are no other options.

    Comment


      #3
      If I test a range, say 'length' = 5-9, I get 5 optimization results - all with the same 'length' of 5 and exactly the same performance results. Even if I was not finding the optimal value and even if the different 'length's did not change the result, I should still get a result for each of the range of the 'length' variable. I do not. Each optimization result shows the same 'length'.

      Comment


        #4
        Originally posted by SteveH View Post
        If I test a range, say 'length' = 5-9, I get 5 optimization results - all with the same 'length' of 5 and exactly the same performance results. Even if I was not finding the optimal value and even if the different 'length's did not change the result, I should still get a result for each of the range of the 'length' variable. I do not. Each optimization result shows the same 'length'.
        Nope. You have it wrong. The optimization will show the best results, period. Not one result for each parameter in the range. That means sometimes, you will get other values: sometimes you will get only one value. It all depends on how the parameters optimize. In which case, if you want to see other values, you might have to make separate optimization runs for each value that you wish to see.

        Comment


          #5
          Originally posted by koganam View Post
          The optimization will show the best results, period. Not one result for each parameter in the range.
          This has not been my experience. While you are correct, it will show the best results, if you have the "Keep best # of results" field set at a value larger than the number of tests, you will get all the results of the optimization. One result for each of the range tested. When I do that I get multiple rows in the 'Optimizer' screen showing the same parameter for the field in question and, of course, the same performance.

          Comment


            #6
            Also, when I added the two new variables into an existing strategy, different 'int' variables that used to optimize correctly now will not change with each optimization iteration.

            Comment


              #7
              Originally posted by SteveH View Post
              This has not been my experience. While you are correct, it will show the best results, if you have the "Keep best # of results" field set at a value larger than the number of tests, you will get all the results of the optimization. One result for each of the range tested. When I do that I get multiple rows in the 'Optimizer' screen showing the same parameter for the field in question and, of course, the same performance.
              And how is that different from what I said? Of course if you ask for the universe of results, you will get the universe for best results, because the universe of best results will be identical to all results.

              The question as posed more or less implied that you were asking for a limited set of results (I assumed the default number). I apologize if I misunderstood.

              Comment


                #8
                Hello SteveH,

                Thank you for your post.

                Can you provide the lines of code used in the Properties region of the code for the variable?

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello SteveH,

                  Thank you for your post.

                  Can you provide the lines of code used in the Properties region of the code for the variable?
                  Here are the two in question. Each will not optimize any requested range.

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int AveRngLen
                  {
                  get { return avernglen; }
                  set { length = Math.Max(10, value); }
                  }

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int MidSmthLen
                  {
                  get { return midsmthlen; }
                  set { length = Math.Max(10, value); }
                  }

                  Comment


                    #10
                    Hello SteveH,

                    Thank you for your response.

                    Is you intention to have the max value greater than 10 or equal to ten, so no values below 10?

                    Comment


                      #11
                      Originally posted by NinjaTrader_PatrickH View Post
                      Is you intention to have the max value greater than 10 or equal to ten, so no values below 10?
                      I've done it like that and like this:

                      [Description("")]
                      [GridCategory("Parameters")]
                      public int AveRngLen
                      {
                      get { return avernglen; }
                      set { length = value; }
                      }

                      [Description("")]
                      [GridCategory("Parameters")]
                      public int MidSmthLen
                      {
                      get { return midsmthlen; }
                      set { length = value; }
                      }

                      Either way, the optimization will display the correct number of iterations of the strategy's performance results based upon the variable's optimization range, but the optimized variable does not change.

                      Comment


                        #12
                        Hello SteveH,

                        Thank you for your response.

                        Let's take this back a few steps, please advise what the minimum value and maximum value you wish to see and the iterations from min to max.

                        Comment


                          #13
                          Here is my optimization result. You can see that "MidSmthLen", the 7th variable, optimizes at "4" for all results when that is outside the optimization range.

                          Comment


                            #14
                            Hello SteveH,

                            Thank you for your response.

                            You would need to make sure you setting the correct values for these parameters. In your provided code using Math.Max() you were set length in the two properties referenced. You would need to change this to following:
                            Code:
                                [Description("")]
                                    [GridCategory("Parameters")]
                                    public int AveRngLen
                                    {
                                        get { return avernglen; }
                                         [B]set { avernglen = Math.Max(10, value); }[/B]
                                    }
                                    
                                    [Description("")]
                                    [GridCategory("Parameters")]
                                    public int MidSmthLen
                                    {
                                        get { return midsmthlen; }
                                        [B]set { midsmthlen = Math.Max(10, value); }[/B]
                                    }

                            Comment


                              #15
                              That was it. Thanks - sometimes you just look right past the obvious.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DawnTreader, Yesterday, 05:58 PM
                              5 responses
                              22 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by kevinenergy, Today, 12:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by ILM8008, Today, 01:31 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post ILM8008
                              by ILM8008
                               
                              Started by swjake, Today, 12:04 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Richozzy38, Yesterday, 01:06 PM
                              6 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X