Thank you.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Optimization
Collapse
X
-
Guest
- Mar 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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment