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

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.
    Emily C.NinjaTrader Customer Service

    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.
        Emily C.NinjaTrader Customer Service

        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.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by andrewtrades, Today, 04:57 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            3 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X