I am a big fan of the Max Strength metric in Strategy Analyzer, but I’d love to make a custom version of it that would penalize any iterations that go above a certain level of drawdown (say $5,000). How would I incorporate the Min Drawdown optimization fitness metric with Max Strength without absolutely preferring the lowest possible drawdown, please? I only want $5,000 and below… not the absolute lowest.
You can write your own Optimization Fitness. In the NinjaScript Editor, open the OptimizationFitnesses folder; the built-in ones are there, so open the Max Strength one, save a copy under a new name, and in OnCalculatePerformanceValue keep its calculation and add a cap before assigning Value: if (Math.Abs(strategy.SystemPerformance.AllTrades.TradesPerformance.Currency.Drawdown) > 5000) Value = -1000000. Iterations under $5,000 drawdown are then ranked by Max Strength as usual, and the rest drop to the bottom instead of being blended into the score. Make the 5000 a property if you want to change it per run. Happy to help further, feel free to DM me.