[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]
Thanks,
Erik
Comment