Custom Metric=w1×(Max Net Profit)+w2×(Max Profit Factor)
Where w1 and w2 are the weights you assign to Max Net Profit and Max Profit Factor, respectively. These weights can be adjusted based on how much importance you want to give to each metric.
namespace NinjaTrader.NinjaScript.OptimizationFitnesses
{
public class MaxProfitFactor : OptimizationFitness
{
protected override void OnCalculatePerformanceValue(StrategyBase strategy)
{
Value = strategy.SystemPerformance.AllTrades.TradesPerformance.ProfitFactor;
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
Name = NinjaTrader.Custom.Resource.NinjaScriptOptimizationFitnessNameMaxProfitFactor;
}
}
}
namespace NinjaTrader.NinjaScript.OptimizationFitnesses
{
public class MaxNetProfit : OptimizationFitness
{
protected override void OnCalculatePerformanceValue(StrategyBase strategy)
{
Value = strategy.SystemPerformance.AllTrades.TradesPerformance.GrossProfit + strategy.SystemPerformance.AllTrades.TradesPerformance.GrossLoss;
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
Name = NinjaTrader.Custom.Resource.NinjaScriptOptimizationFitnessNameMaxNetProfit;
}
}
}

Comment