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

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 rexsole, Today, 08:39 AM
      0 responses
      4 views
      0 likes
      Last Post rexsole
      by rexsole
       
      Started by trilliantrader, Yesterday, 03:01 PM
      3 responses
      30 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      4 responses
      26 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Brevo, Today, 01:45 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      74 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Working...
      X