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 Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,767 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      9 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      7 views
      0 likes
      Last Post rocketman7  
      Working...
      X