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

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.
    JimNinjaTrader Customer Service

    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 rdtdale, Today, 01:02 PM
      0 responses
      1 view
      0 likes
      Last Post rdtdale
      by rdtdale
       
      Started by alifarahani, Today, 09:40 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      18 views
      0 likes
      Last Post RookieTrader  
      Started by PaulMohn, Today, 12:36 PM
      0 responses
      6 views
      0 likes
      Last Post PaulMohn  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      40 views
      0 likes
      Last Post love2code2trade  
      Working...
      X