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

An Error within the Genetic Optimizer

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

    An Error within the Genetic Optimizer

    Hi NinjaTraders,

    While I use the default Genetic Optimizer to run some optimization. The Genetic Optimizer searches outside my searching steps. To be specific, The first parameter "Multiples" is set to have a step value of 0.1, while the GO gives some ridiculous results in which the 'Multiples' has a value of E-14. As shown in the following grid.
    Performance Parameters
    2.63 // 8.35977640182701/0.00485184988679916/0.02 (Multiples,Threshold,PercentToRisk)
    2.49 // 8.9/0.0045/0.02 (Multiples,Threshold,PercentToRisk)
    2.49 // 9/0.0044/0.02 (Multiples,Threshold,PercentToRisk)
    1.93 // 4.8/0.0047/0.02 (Multiples,Threshold,PercentToRisk)
    1.72 // 4.9/0.0046/0.02 (Multiples,Threshold,PercentToRisk)
    1.67 // 6.1/0.004/0.02 (Multiples,Threshold,PercentToRisk)
    1.66 // 4.8/0.0049/0.02 (Multiples,Threshold,PercentToRisk)
    1.62 // 6.8/0.0047/0.02 (Multiples,Threshold,PercentToRisk)
    1.53 // 4.5/0.0043/0.02 (Multiples,Threshold,PercentToRisk)
    1.01 // 6.3/0.0032/0.02 (Multiples,Threshold,PercentToRisk)

    I am using the latest version. NT 8.0.18.1

    Can you just fix this error ?

    #2
    Hello wolfcuring, thanks for your post.

    Could you please post a reduced version of the script so I can test and report if needed?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Sure. Steps for the strategy: Multiples 0.1; Threshold 0.0001; Percent 0.02;

      When using GO by the paras in the attached picture. There will be at least one result given is out of the steps.
      Attached Files

      Comment


        #4
        Hello wolfcuring, thanks for posting that.

        I am not able to reproduce what you are seeing. Could you kindly save a template of your strategy analyzer setup and post it here so I can test the exact parameters you are?
        • Set up the strategy so that it reproduces the problem.
        • At the bottom right of the Strategy Analyzer, click Template>Save
        • The saved template can be found under Documents\NinjaTrader 8\templates\Strategy\MBOS
        I look forward to your reply.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          Thank you for your reply. I have been out for a week.

          The template I uploaded is in extension of "zip", because xml is not allowed to upload (wired). So you need to change the extension back to xml. (Same thing with the result of my run, in the xlsx file)

          Attached Files

          Comment


            #6
            Hi wolfcuring,

            It looks like your .zip files are empty, you must right click the .xml file>Send To..>Compressed (zip) folder. This will compress the file so it can be uploaded to the forum.

            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi Chris,

              Thank you for your help. Hope it will work this time.
              Attached Files

              Comment


                #8
                Hi wolfcuring, thanks for posting that.

                I am not able to reproduce this, see this screen shot:



                Could you post a screenshot of this problem occurring in the platform itself and describe how I can reproduce this?

                I look forward to hearing from you.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chirs,

                  The screen shot you posted, if you check carefully, the first line of the parameter set, Multiples and Threshold went into E-14. Which is not supposed to happen if we expect all searching results are within the search steps.

                  So, the search step for Multiples is 0.1, and Threshold 0.0001; in the first line, the they went into E-14; that is going out of the search steps.

                  Comment


                    #10
                    Hi wolfcuring,

                    Are you referring to the significant figures? The values for multiples is in between 1 and 6 and the Threshold is in between 0.001 and 0.006.

                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chris,

                      You see, the searching space as it is supposed to be, should be contained in the range of parameters and individual parameter set in it should be restricted by the increment or search step. Here, the range for Multiples is [1,6]; and the range for Threshold is [0.0015, 0.006]. A legitimate individual within this space should be controlled by the search step, which is 0.1 for Multiples and 0.0001 for Threshold.

                      For example, legitimate individual parameter set in the search space is something like this:
                      (1.2, 0.0016) /Multiples, Threshold;
                      (1.3, 0.0021) ;
                      (3.5, 0.0046) ;
                      (5.7, 0.0055) ;
                      ...

                      While some parameter set like this:
                      (2.47569809876876, 0.00217898765678)

                      is out of the constrain of search steps. It is not a legitimate member of the search space. The Genetic Optimizer is doing search out of the steps I desired. This is not supposed to happen, as I have specified the search steps(0.1 and 0.0001).

                      So put it this way, Genetic Optimizer is supposed to search Multiples in the array [1, 1.1, 1.2, 1.3, 1.4, 1.5...6]; and Threshold in [0.0015, 0.0016, 0.0017, 0.0018, 0.0019 ... 0.006]. Any value between these steps are not supposed to show up. So, 2.47569809876876 is not supposed to show up. And this is probably a programming error.

                      In the screen shot you posted early, the parameter set in the first line is something in E-14. And that is an error.

                      Comment


                        #12
                        Hi wolfcuring, thank you for the clarification. This would be unexpected, and I can reproduce this on my end so I'll report it to my supervisor and update this thread with more info on a fix.

                        Thanks in advance for your patience.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks Chris.

                          And some other advice is that the parameters by the GO seem wired, like stability rate, reset rate. And they are not well documented. I am studying the GeneticSharp package, and essential parameters for a GA is: population, fitness, selection, crossover, mutation plus termination method. I am not sure whether stability rate is a optimized algorithm for NT 8 or just dispensable?

                          Comment


                            #14
                            Hello wolfcuring, thanks for your reply.

                            If you are referring to "Stability size", that is used to prevent stagnation of parents that generate the same children. If the top performing stability size percentage of children are the same as the top performing stability size percentage of their parents then the parents are reset and a new generation is made.

                            Best regards.
                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Has a fix been found for this?
                              I'm seeing the same thing.
                              For example: specifying min;max;increment of -1.0;0.0;0.10; the GO will sometimes try -1.10, (the min is -1.0)
                              The hack that seems to work (so far) is to use integers for the strategy input and divide when the call to the indicator is made.​​​

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by mjairg, 07-20-2023, 11:57 PM
                              3 responses
                              213 views
                              1 like
                              Last Post PaulMohn  
                              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                              4 responses
                              544 views
                              0 likes
                              Last Post PaulMohn  
                              Started by GLFX005, Today, 03:23 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post GLFX005
                              by GLFX005
                               
                              Started by XXtrader, Yesterday, 11:30 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post XXtrader  
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Working...
                              X