Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Walk-Forward Custom Fitness (How to Eliminate Negative Optimizations) ?

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

    Walk-Forward Custom Fitness (How to Eliminate Negative Optimizations) ?

    Dear all,

    Is there a way to make the Walk-Forward process to only Forward-Test the Parameters that had a Positive Net-Profit on the optimization?


    for example:

    Optimization Result # 1 (Best Parameters 5/3/5) +$1000 ==> Forward-Test.
    Optimization Result # 2 (Best Parameters 5/2/1) +$2500 ==> Forward-Test
    .
    Optimization Result # 3 (Best Parameters 2/9/6) -$1700 ==> Don't Forward-Test.
    Optimization Result # 4 (Best Parameters 4/2/3) +$2500 ==> Forward-Test
    .
    Optimization Result # 5 (Best Parameters 2/8/7) -$4000 ==> Don't Forward-Test.


    PHP Code:
    protected override void OnCalculatePerformanceValue(StrategyBase strategy)
    {
           Value = strategy.SystemPerformance.AllTrades.TradesPerformance.NetProfit;
    } 
    

    Thank you.

    #2
    Hello PrQuantumH,

    Thank you for your post.

    I am not aware of a way to make the walk forward optimization only process parameters that had a positive net profit. You could set the optimizer to optimize on max net profit, though there is no way to stop forward testing if the max net profit is a negative number. I have submitted this as a feature request to the Development Team. I will follow up with an internal tracking number for your reference as soon as it is created.

    Thanks in advance for your patience.

    Comment


      #3
      Thank you Emily. I would really appreciate adding this feature.

      Currently, I'm thinking of coding a workaround for it. Is there a way to know from inside the strategy script (or from the custom Fitness Script) that the currently running test is categorized as Optimization or as a Backtest (Forward-Test).

      The initial idea would be, coding a global variable that can allow the next use of the strategy (for a backtest Forward-Test) only if the previous use of the strategy (Optimization) was having a positive Net-Profit.

      Regards,

      Comment


        #4
        Originally posted by PrQuantumH View Post
        Thank you Emily. I would really appreciate adding this feature.

        Currently, I'm thinking of coding a workaround for it. Is there a way to know from inside the strategy script (or from the custom Fitness Script) that the currently running test is categorized as Optimization or as a Backtest (Forward-Test).

        The initial idea would be, coding a global variable that can allow the next use of the strategy (for a backtest Forward-Test) only if the previous use of the strategy (Optimization) was having a positive Net-Profit.

        Regards,
        Hello,

        Thank you for your note.

        Though it is not documented not supported, there is a StrategyBase.Category enum that may be used to determine which mode the strategy is running in from within the Strategy Analyzer. This is mentioned in the following forum post:


        You could try using this in your workaround, though we are unable to guarantee the behavior of using this in your strategy.

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

        Comment


          #5
          Hello PrQuantumH,

          Thanks for your patience.

          The internal tracking number for your feature request is SFT-6043. Please reference this internal tracking number when contacting Platform Support if you ever have questions regarding this feature request.

          When a feature request is implemented, you'll find a description of the new feature in the release notes:Thank you for using NinjaTrader.​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          563 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          329 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X