Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Strategy Optimization for More Balanced Monthly Profit

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

    Help with Strategy Optimization for More Balanced Monthly Profit

    Hello,

    I need some help with Optimizaion for my strategy.

    Currently, I'm backtesting my custom NinjaScript strategy using Optimization over the past year. If I select to optimize for 'max net profit' or use the multi-objective optimization and select a couple of fitness options (i.e. max net profit & max drawdown), I get results that are very extreme over the months backtested. For example, I may see a loss for several months, minimal profit on several more months and then extreme profit on one or two months. The one month of extreme profit is fulfilling the 'max net profit' objective. However, I'm having trouble finding a happy medium.

    What I would like to find is an optimization that provides less profit overall but a more average profit for each month. In other words, I'd rather see $200/month profit across almost all months rather than $5000 profit one month and losses or breakevens on the rest.

    Although I have read through the definition of the various fitness optimization objectives, I admit that I don't fully understand all (most) of them.

    How do I set up (multi-objective) optimization to find the highest monthly average profit instead of the extreme overall net profit?

    Thanks!

    #2
    Welcome to the forums InfraredBusa!

    I would suggest making a custom Optimization Fitness Metric to accomplish the task.

    The goal would be to organize trades from strategy.SystemPerformance.AllTrades in OnCalculatePerformanceValue so you can:
    1. Collect Trades By Month, (a Dictionary<string, List<NinjaTrader.Cbi.Trade>> may be suitable, where the string is the Month + Year from each trade)
    2. Loop through the trades of each month to find an average for each month (This could then be added to new Dictionary<string, double> to track the monthly average per for each Month + Year)
    3. Loop through averages of each month to find a total average based on Monthly averages
    Further code could be added to ignore adding trades with extreme profits or exclude months with extreme profits to fine tune your metric.

    Optimization Fitness Metrics are rather simple, but you may find documentation here - https://ninjatrader.com/support/help...on_fitness.htm

    We look forward to assisting.

    Comment


      #3

      Thank you Jim for the detailed answer! I'll start working on it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      56 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      132 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 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