Choosing an Optimization Objective and Constraints
In parameter optimization, the objective is the single metric the search maximises or minimises, and constraints are guards that disqualify degenerate winners. Choosing them well matters more than the search method: optimize the wrong objective and even a perfect search will hand you a strategy that looks excellent on paper and is untradeable in practice.
Key principle
The search will exploit exactly what you tell it to reward. If the objective is raw return with no constraints, it will find the combination that took the most risk — usually one lucky trade or a ruinous drawdown. Constraints exist to rule those winners out before they reach your leaderboard.
What objectives are available?
backtester.run supports seven objectives to maximise, each capturing a different aspect of strategy quality. The right choice depends on what you care about most — risk-adjusted return, worst-case loss, or trade-by-trade profitability.
| Objective | Rewards | Watch out for |
|---|---|---|
| Sharpe ratio | Return per unit of total volatility | Penalises large upside swings too |
| Sortino ratio | Return per unit of downside volatility | Needs enough losing trades to estimate downside deviation |
| Calmar ratio | Annual return per unit of max drawdown | Sensitive to a single worst drawdown |
| Total return / CAGR | Raw growth | Ignores risk — favours the most aggressive set |
| Profit factor | Gross profit ÷ gross loss | Can be high with very few trades |
| Win rate | Share of winning trades | Meaningless without win/loss size |
Max drawdown and volatility are also available as objectives to minimise — useful when the goal is the calmest equity curve rather than the highest return.
Why a raw-return objective is dangerous
Maximising total return or CAGR rewards risk-taking with no penalty. Given free rein, the search gravitates toward the parameter set with the largest position concentration or the single biggest winning trade — precisely the result least likely to repeat. A strategy that doubled its capital on one enormous position during a historical spike is not a good strategy; it is a lucky one. Risk-adjusted objectives correct this by dividing return by a risk measure, so the search is forced to find combinations that earn their returns consistently rather than accidentally.
Constraints as guardrails
Even a good objective can be gamed by degenerate parameter sets: a single perfectly-timed trade, a strategy that never loses because it almost never trades, or a combination whose drawdown would be psychologically impossible to hold. Constraints are the firewall. backtester.run evaluates every constraint before adding a trial to the leaderboard — any trial that violates an enabled constraint is dropped entirely, regardless of its objective score.
| Constraint | Disqualifies a trial when | Why it matters |
|---|---|---|
| Minimum trade count | Too few trades | Few trades cannot prove an edge — the single most important guard |
| Maximum drawdown | Worst loss exceeds your absolute % limit | Keeps winners within tolerable risk |
| Minimum Sharpe | Risk-adjusted return too low | Floors the quality of accepted sets |
| Minimum win rate | Win rate below threshold | Optional comfort guard; weak when used alone |
Of all the constraints available, the minimum trade count is the most important. A 3-trade strategy with a perfect win rate is not evidence of an edge; it is noise wearing a good-looking mask. Without a floor on trade count, the search will inevitably surface parameter sets that traded twice in three years with spectacular-looking numbers. The statistical problem here is directly related to the deflated Sharpe ratio: the more trials you run, the more any reported performance figure is inflated by the multiple-comparisons effect, and a low trade count amplifies that inflation dramatically. Setting a minimum trade count appropriate to your history length — typically at least 30 trades — is the single most effective step you can take to keep leaderboard results meaningful.
The maximum drawdown constraint is checked against the absolute drawdown as a percentage of peak equity. A 25% maximum drawdown constraint drops any trial whose worst peak-to-trough loss exceeded 25%, regardless of how high the Sharpe or profit factor looked. This keeps the leaderboard populated with strategies you could realistically hold through a bad stretch rather than those that would have required a stomach of steel.
A sensible default
For most strategies, the right starting point is straightforward: maximise the Sharpe ratio, subject to a minimum trade count matched to your history length and a maximum drawdown you could genuinely tolerate without abandoning the strategy in a live drawdown. This combination rewards consistent risk-adjusted performance, rules out fragile rarely-trading peaks, and keeps risk within human limits. Once optimization produces a winner, validate it with walk-forward analysis on out-of-sample data, and check that the winning parameters sit on a plateau, not a peak — a broad region of similarly strong results signals a genuine edge, while an isolated spike signals that the search found a lucky corner of parameter space.
Optimize toward the right objective
backtester.run lets you pick the objective and set constraints — minimum trades, maximum drawdown — for every optimization, so your leaderboard only contains parameter sets worth trading. Start from a plain-English strategy.
Start free →Frequently Asked Questions
- What is the objective in strategy optimization?
- The objective is the single metric the search tries to maximise or minimise. Every parameter combination is scored on it and ranked by it, so the objective defines what 'best' means. Optimizing the wrong objective produces a strategy that scores well on paper but is not worth trading.
- Should I optimize for total return or a risk-adjusted metric?
- Almost always a risk-adjusted metric. Optimizing raw return rewards whatever combination took the most risk, which often means one lucky trade or a catastrophic drawdown. The Sharpe or Sortino ratio rewards return per unit of risk, producing strategies you can actually hold.
- What is the difference between Sharpe, Sortino, and Calmar?
- All three are risk-adjusted return ratios with different risk measures. Sharpe divides excess return by total volatility. Sortino divides by downside volatility only, so it does not penalise upside swings. Calmar divides annual return by maximum drawdown, focusing on worst-case loss.
- What are constraints in optimization?
- Constraints are guards that disqualify a parameter set regardless of its objective score. backtester.run supports a minimum Sharpe, a maximum drawdown, a minimum trade count, and a minimum win rate. Any trial that violates an enabled constraint is dropped from the leaderboard.
- Why is a minimum trade count the most important constraint?
- A handful of trades cannot establish a real edge — a 3-trade strategy with a perfect record is noise, not signal. A minimum trade count forces the search to find parameters that trade often enough for the result to be statistically meaningful, killing degenerate winners.
- What is a sensible default objective and constraints?
- Maximise the Sharpe ratio, subject to a minimum trade count appropriate to your history and a maximum drawdown you could actually tolerate. This rewards consistent risk-adjusted performance while ruling out the fragile, rarely-trading peaks that overfitting tends to find.