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

Is it possible to randomize the number of iterations in the optimizer?

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

    Is it possible to randomize the number of iterations in the optimizer?

    Hi NinjaTraders,

    I am using a third party package called GeneticSharp to run some Genetic Algorithms on the NT 8. I got it running. But the problem is, NT 8 requires that the NumberofInterations be configured in advance. While the GeneticSharp package has other ways to terminate the algorithm, for example, it would allow the GA to stop after a number of performance stagnation (for example, if the algorithm's performance does not improve after 100 iterations, it will stop).

    So, I set the NumberofIterations as 1/10 of the possible iterations as a compromise, While this certainly undermines the power of a GA.

    So, it it possible to allow some randomness in setting the NumberofIterations? Or, let the program decide how many iterations it needs to run ?


    #2
    Hello wolfcuring, thank you for your post.

    I will submit a suggestion to our development team to take a look at other ways of ending the optimization based on the metadata of the optimization itself. Such as ending the optimization if performance stagnation is detected as mentioned.

    Best regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris, hope that become possible soon.

      Comment


        #4
        Hi Chris,

        My new finding is that the NumberOfIteration argument can be circumvented! I do this by set up the NumberofIteration to a very small fraction of possible iterations, for example, 1%, which is impossible to complete the search. While I use the stagnation method to stop the GA, for example, when the performance does not improve in the last 100 iterations, stop the GA. And check whether the stagnation is reached, it always returned True ! I can confirm this, because I used the brute force search to know the best parameter set in before I test the GA. So, even I set the NumberfoIteration to just 1, the GA still reached its stagnation. So I guess that is clear evidence that the NumberofIterations is circumvented.

        Another evidence is that, when I set the GA to stop by exact number of iterations, it is stuck by the last time of iteration. And I guess the Number of iterations set within the GA is in conflict with NumberofIteration set up by the OnOptimize() method.

        By the way, I used the RunIteration() method within the GA I coded.

        Comment


          #5
          Hello wolfcuring, thanks for your reply.

          I'm glad you were able to find a solution. If I can assist any further please let me know. Please also feel free to share your solution with the forum if you wish.

          Kind regards.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Hi Chris,

            By the way, is it possible for NT8 to count how many times has the RunIteration() method been called?

            Thank you !
            Best,

            Comment


              #7
              Hello wolfcuring, thanks for your relpy.

              This can be done if you make an Optimizer script, or you could make a copy of an existing one to add a counter.

              Please let me know if I can assist any further.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hi Chris,

                Can you be more specific? Is there a counter come with the NinjaTrader ? I looked elsewhere in C# which seems to be quite complicated.

                Thank you !

                Comment


                  #9
                  Hello wolfcuring, thanks for your reply.

                  A counter can be something like a class level integer variable that you increment. You may review all of the optimizer scripts in the platform, they are located under the "Optimizers" folder in the NinjaScript editor.

                  Kind regards.
                  Chris L.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bmartz, 03-12-2024, 06:12 AM
                  5 responses
                  32 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by Aviram Y, Today, 05:29 AM
                  4 responses
                  13 views
                  0 likes
                  Last Post Aviram Y  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  3 responses
                  28 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by gentlebenthebear, Today, 01:30 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by cls71, Today, 04:45 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X