Thank you.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Optimization
Collapse
X
-
Guest
- May 2026
Optimization
Is there an option to perform optimization maximizing geometrical mean, if not, is it possible to modify NT to do this manually?
Thank you.Tags: None
-
BoyPlunger
Thank you. It seem easy to program and I have done so but for some reason it does not work properly. I followed your instructions and copied and modified one of the existing optimization files, it is just a few lines. The optimization process is running ok but all values of performance have the same value 1. Did I miss anything?
Here is my code:
//
// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
//
#region Using declarations
using System;
using System.ComponentModel;
using System.Drawing;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// </summary>
[Gui.Design.DisplayName("max. geo. mean")]
public class MaxGeoMean : OptimizationType
{
/// <summary>
/// Return the performance value of a backtesting result.
/// </summary>
/// <param name="systemPerformance"></param>
/// <returns></returns>
public override double GetPerformanceValue(SystemPerformance systemPerformance)
{
double gmean = 1;
for (int i=0;i<systemPerformance.AllTrades.Count;i++)
{
Trade myTrade = systemPerformance.AllTrades[systemPerformance.AllTrades.Count - 1 - i];
gmean = gmean * (1+myTrade.ProfitPercent);
}
gmean = Math.Pow(gmean,1.0/systemPerformance.AllTrades.Count);
return(gmean);
}
}
}
Comment
-
Hello BoyPlunger,
Unfortunately custom optimization is beyond what we could support but you can refer to the DefaultOptimizationMethod.cs file located in the folder C:\Users\JMitra\Documents\NinjaTrader 7\bin\Custom\Type\ to get an idea on how to create custom Optimization methods.
Please let me know if I can assist you any further.JoydeepNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
60 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
146 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
161 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
97 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
284 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment