Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Interesting issue with optimizer

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

    Interesting issue with optimizer

    Hi,

    This may have been discussed somewhere but I have not found any reference to it.

    The genetic optimizer appears to rerun at the end of the optimization whichever iteration proves to be the best. I can print out the iterations from the genetic optimizer (in the Type folder) and after all the iterations are complete, I get one extra strategy execution with the parameter set from the winning iteration.

    Is there a reason for this or is it "just the way it works" or am I misinterpreting the results?

    I noticed this because I am writing the trade results to a SQL Server database in the genetic optimizer and kept getting duplicate key errors at the very end of the optimization run.

    Best Regards,
    Scott

    #2
    Hi Scott,

    Thanks for the post. I was not able to reproduce this. Attached script, output, and screenshot. The winning result of 7, 25 is only outputted once. Can you think of any changes needed in this test where we could see this occur on our side?
    Attached Files
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan, thanks for getting back to me. I didn't mean it was in the output window (the one you showed in the screenshot) but rather the code executes a second time.

      If you put a print statement in OnStartUp you will see it executes once per iteration and then once again at the end of the optimization.

      Best Regards,
      Scott

      Comment


        #4
        I moved the Print statement to OnStartup() but still get the same results. Winning result 7, 25 is only shown once.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by ScottB View Post
          Hi,

          This may have been discussed somewhere but I have not found any reference to it.

          The genetic optimizer appears to rerun at the end of the optimization whichever iteration proves to be the best. I can print out the iterations from the genetic optimizer (in the Type folder) and after all the iterations are complete, I get one extra strategy execution with the parameter set from the winning iteration.

          Is there a reason for this or is it "just the way it works" or am I misinterpreting the results?

          I noticed this because I am writing the trade results to a SQL Server database in the genetic optimizer and kept getting duplicate key errors at the very end of the optimization run.

          Best Regards,
          Scott
          I do not think that it reruns the best result; it just reports it as a summary. As that summary report is just a duplicate of the actual test run report, it would probably flummox anything that is recording all output, if the records are required to be unique.

          Comment


            #6
            koganam, you may well be correct. I know OnStartUp executed again and the error came out of a method only called in OnBarUpdate but as always, I may have it wrong. Under any circumstances, I was able to fix the issue it was causing with the database.

            I am always loath to fix an issue that may be masking a more subtle yet more serious issue.

            Best Regards,
            Scott

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            77 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            45 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            27 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            63 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X