Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy optimization causing lag?

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

    Strategy optimization causing lag?

    Does the strategy optimization use the same core as the charts? I'm experiencing extreme lag while optimization is running. If so, this should come with a warning. I'm glad I wasn't in the middle of a trade! It even takes NT 20 seconds or more just to register a click on the main platform page! Yet, Firefox will load and allow me to post this message.

    #2
    It's not a core issue.... cpu usage is under 5%. It's a memory issue. I have 16 gb showing 86% usage, plus an SSD which is at almost 30%.

    Comment


      #3
      NT was completely unresponsive. I could shut close individual NT windows but the main platform window would not respond.

      Comment


        #4
        Hello Chippy,

        Thank you for your posts.

        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.

        I don't know 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.

        Temporarily commenting out drawing objects when backtesting can also reduce memory load.

        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:

        https://ninjatrader.com/support/help..._algorithm.htm

        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:

        https://ninjatrader.com/support/help...niteration.htm

        My colleague Jim created a video demonstrating how the SampleMACrossover strategy, a simple strategy that utilizes IsInStantiatedOnEachOptimizationIteration=false for efficiency, can still quickly utilize memory resources.

        Demo — https://drive.google.com/file/d/15pz...w?usp=drivesdk

        We should consider the following for memory consumption:

        Data * Strategy resources * Number of optimization iterations * Number of trades * Keep best # of results.

        As we can see there are a number of factors that are involved and memory utilization can climb very quickly depending on a few of these factors. Once memory gets maxed out, we can experience short freezes where memory is decommitted, stored to disk, and then new resources are committed before the backtest is resumed.

        Further reading that may be helpful:

        Optimization Tips — https://ninjatrader.com/support/help...ionPerformance

        Walk Forward Optimization — https://ninjatrader.com/support/help...ss_metrics.htm

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

        Comment


          #5
          As usual, awesome post, Kate. Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X