Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

max. avg. profit ratio

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

    max. avg. profit ratio

    Code:
    [FONT=Courier New][COLOR=black]public override double GetPerformanceValue(SystemPerformance systemPerformance) {I am trying to create a new OptimizationType I looked at the SQN one that has been posted as an example I was wondering if someone could take a look at mine and see if it looks correct. It is supposed to be a ratio of average profit percent divided by its standard deviation. The code is: 
    
    
    [FONT=Courier New][COLOR=black]double TotalVariance = 0;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]double StdDev = 0;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]int TotalTrades = 0;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]foreach (Trade trade in systemPerformance.AllTrades) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]TotalVariance += Math.Pow((trade.ProfitPercent * trade.Quantity) - systemPerformance.AllTrades.TradesPerformance.Percent.AvgProfit, 2);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]TotalTrades += trade.Quantity;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]if ((TotalVariance != 0) && (TotalTrades != 0)) StdDev = TotalVariance / TotalTrades;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]return systemPerformance.AllTrades.TradesPerformance.Percent.AvgProfit / StdDev;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=black]}[/COLOR][/FONT]
    [/COLOR][/FONT]
    Thanks,
    Erik

    #2
    Hello ErikHR,

    Unfortunatley this is beyond our scope of support but hopefully you can get some input from other users who have tried similar.

    If you've not checked already, you can see the file used for default optimization:
    My Documents\<NinjaTrader>\bin\Custom\Type\@DefaultOp timizationMethod.cs
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I am acutally just looking for some otheer users to look at the standard deviation calculation to see if it looks correct, so if anyone gets time to look at it, I would greatly apreciate it.

      Thanks,
      Erik

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 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
      548 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X