Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to determine if Strategy is being Backtested or Optimized in Strategy Analyzer

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

    How to determine if Strategy is being Backtested or Optimized in Strategy Analyzer

    The reason I ask is that it works better to turn off plotting and drawing during Optimize but not Backtest.

    Is there a way to distinguish between them?
    Backtest type Sets the backtest type.

    1. Standard

    2. Optimization
    I pasted the two options you can see in the strategy analyzer.

    Right now, I have all plotting and Drawing turned off when Account.Name == @"Backtest";

    Is there a more precise way?

    #2
    Hello SapientTrader,
    Thanks for your post.

    I was able to check the number of Optimizer iterations in order to differentiate between backtest and optimization, but I also needed to access an undocumented variable in order to ensure I was in the Strategy Analyzer. IsInStrategyAnalyzer is not documented so I cannot make any guarantees on its usage or provide any support for it going forward. Something like the following snippet will print "true" if the optimizer is being used and "false" if in a backtest.

    Code:
                if(Optimizer != null && IsInStrategyAnalyzer)
                    Print("in optimization ?  " + (Optimizer.NumberOfIterations > 1 ? "true" : "false" ));

    Please let me know if we can be of further assistance.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi there,

      after testing this code

      Code:
      Optimizer.NumberOfIterations
      is greater than 0 only once on the what I believe to bet the initialization run, when the real testing starts it's 0.
      While I find this useful for different reasons, here is another approach:

      https://ninjatrader.com/support/foru...eing-optimized

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      54 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      72 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X