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


How to get faster Optimization Times

  • Filter
  • Time
  • Show
Clear All
new posts

    How to get faster Optimization Times

    Hello Everyone,

    I been running this optimization for 10 hours so far. I am using 1 tick fill order resolution and testing range bars.

    How do I get faster optimization times? Do I need a high performance server?

    Thank you,

    Hello simple_goodoboy,

    Thank you for your post.

    From your screenshot, I see you're running optimizations using the Default Optimizer option on your strategy. We'd expect that using 1 tick high order fill resolution would take some time.

    The NinjaTrader optimization engine is optimized to take advantage of as much system resources as possible, and it is advisable not to trigger an optimization during a time where you would need to be using the PC. However, there are a number of ways in which you may be able to reduce your CPU and memory usage during an optimization run as well as potentially speed up the process.

    I can't tell how many parameters you are optimizing your strategy on, but strategies with a relatively large number of parameters for optimization can multiply the impact on your PC resources.

    When working with strategies with a large number of parameters, avoid using "1" as the increment value for the parameters, to avoid forcing the optimizer algorithm to run the maximum number of permutations. Changing the increment value to as little as "2" can cut the number of permutations in half.

    Also, you may want to try testing using the Genetic algorithm instead of the Default. The default algorithm tests every single combination of parameters within the optimization range to find the best possible result. For more complicated optimizations this can take some time to complete, as you've seen. The Genetic algorithm, on the other hand, can be more useful for more extensive optimizations, because it doesn't test every combination - instead, it works on something similar to evolution via natural selection.

    Genetic optimization will find the approximate optimal solutions, but since it doesn't test every possible combination it's not guaranteed that the optimization would be the absolute best.

    Here's a link to our help guide that goes over Genetic optimization:

    If this is a strategy you have coded yourself, there is also the IsInstantiatedOnEachOptimizationIteration property you can set in State == State.Configure.

    The default behavior of the Optimizer is to re-create the strategy for each optimization run. However, this process requires more time and computer resources to return results, which could impact the amount of time it takes to run an optimization.

    When this property is set to false, the strategy is re-used to save time and computer resources. When this is set to false, internal properties are reset to default values after each iteration, but it is possible that user-defined properties and other custom resources may carry their state over from the previous iteration into a new backtest run. To take advantage of performance optimizations, developers may need to reset class level variables in the strategy otherwise unexpected results can occur.

    You can find out more information regarding this property in our help guide link below:

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service


    Latest Posts


    Topics Statistics Last Post
    Started by Christopher Leggit, Today, 01:54 AM
    0 responses
    Last Post Christopher Leggit  
    Started by WHICKED, Yesterday, 11:12 PM
    0 responses
    Last Post WHICKED
    by WHICKED
    Started by AdeptistJune, Yesterday, 08:08 PM
    1 response
    Last Post bltdavid  
    Started by GKbowen, Yesterday, 04:03 PM
    3 responses
    Last Post bltdavid  
    Started by bojim, Yesterday, 08:35 PM
    0 responses
    Last Post bojim
    by bojim