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

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 helpwanted, Today, 03:06 AM
      1 response
      7 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      7 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X