Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimizer fitness stops when finding a match

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

    Optimizer fitness stops when finding a match

    Hello,

    I have been developing an optimizer fitness that matches with my needs.

    When I optimize a strategy using one of the optimizer fitnesses that come with NT8 by default the optimizer behaves correctly. But, when I apply mine, the optimization stops when finding a match instead fo finishing the optimization process and displaying all the results.

    I explain what are the goals of my optimizer fitness and I show the code:
    • I want only to be displayed the optimization results that offer a minimum number of trades. I prefer the results with a higher number of trades.
    • I want the code to loop through all the trades and discard the optimizations with trades that do not match a certain criterion and I do not want them to be shown in the result list of the optimization.

    The code is attached.

    I just would like to know why my code makes the optimization to stop when finding a match instead fo finishing all the process like it happens with the default fitnesses that come by default with NT. If you want it to test you can use SampleMACrossover strategy.


    Attached Files

    #2
    Hello Guillembm,

    Thank you for your post.

    I recommend adding Print() statements to assist you in debugging your script. You could add prints both inside and outside of your loop that include the values for numTrades, AllTrades.Count, ProfitPercent, IsMinimumCriteria, etc. in order to observe the values of these items and how they update as the script runs. Additionally, keep an eye out for any errors in the NinjaScript Output window and the Log tab of the Control Center.

    For more information about using prints to help debug a script:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Hello,

      I have been printing all steps fo the code and I made changes on it, but the result is always the same. It stops when finding a match.

      I get no error messages.

      Comment


        #4
        Hello guillembm,

        Thank you for your reply.

        What are the strategy analyzer settings you are using for your optimization? Please provide a screenshot.
        • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
        • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
        ​Do you achieve the same results where the optimization fitness stops after a match when running the optimization on the SampleMACrossover strategy?

        I appreciate your patience and look forward to your reply.

        Comment


          #5
          Hello again,

          When testing I am finding this error:
          "'MyOptimizer' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load COST Default: 450 Minute"

          I read in the forum posts that this error is generated when adding another dataseries with AddDataSeries() but I am not using AddDataSeries() in my strategy. How can I avoid this?. When this error occurs the strategy stops and the results appear blank.

          Comment


            #6
            Hello guillembm,

            Thank you for your reply.
            • Do you receive the same error when trying to load the same strategy analyzer settings on the SampleMACrossover strategy that comes with NinjaTrader?
            • Is this occurring on a strategy that you developed or was it imported from a third party?
            • I am still curious; what are the strategy analyzer settings you are using?
              • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
              • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
            I look forward to your reply.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            627 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            359 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            562 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            567 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X