Hello everyone,
I would like to suggest an improvement for the ProBacktest optimization module.
At the moment, optimization is mainly based on predefined performance criteria such as total gain, win rate, max drawdown, max run-up, etc. These are useful, but they do not always describe what a trader really wants to optimize. ProBacktest already supports coded trading systems and variable optimization, but the optimization target itself seems limited to fixed metrics. (ProRealCode)
It would be extremely useful if ProRealTime allowed users to define their own optimization or loss function directly in the strategy code.
For example, instead of optimizing only for maximum profit, I might want to optimize for a combination of:
net profit
minus drawdown penalty
minus volatility of the equity curve
minus penalty for too few trades
plus reward for smooth/linear equity growth
A possible implementation could be something like:
myLossFunction = StrategyProfit - 2 * MaxDrawdown + 1000 * LinearityScore
OPTIMIZEON myLossFunction
Or, if fully custom loss functions are too complex, a simpler first step could be to add a linearity coefficient between 0 and 1.
The idea would be:
- Draw a straight reference line between the equity value after the first trade and the equity value after the last trade.
- Compare the actual equity curve to this line.
- Calculate a correlation or fit score between 0 and 1.
- Allow this value to be used as an optimization criterion.
This would help identify strategies with smoother and more stable equity curves, instead of strategies that only show high final profit because of one or two lucky trades. In practice, many traders prefer a strategy with slightly lower profit but a much more regular equity curve, because it is often easier to trust and manage in live trading.
This feature would also help reduce over-optimization based only on profit, win rate, or drawdown. A custom objective function would allow each trader to define what “good performance” means for their own risk profile and trading style.
So my suggestion is either:
Option 1: Allow a user-defined optimization/loss function in ProBacktest code.
Option 2: Add a built-in “linearity” optimization metric.
I think this would be a very powerful addition to ProBacktest and ProOrder development, especially for users who care about robustness and consistency, not only maximum backtest profit.
What do you think? Would anyone else find this useful?