You've built a strategy and it works. Now the obvious question: would it work better with different parameters? What if the EMA window is 30 instead of 20? What if the RSI threshold is 65 instead of 60?

A parameter sweep answers this systematically, but it also creates the risk of overfitting. This guide shows how to run a sweep with the Quant agent, read the heatmap result correctly, and choose parameters that are robust rather than cherry-picked.

1. When to run a parameter sweep

Run a sweep after you have a working strategy with a positive Sharpe and a plausible thesis. Don't sweep first. If the thesis is wrong, sweeping just finds the best way to lose money.

Good times to sweep:

  • You have a signal but you're uncertain about the right lookback period
  • You want to confirm that the strategy isn't uniquely sensitive to one parameter value
  • You're choosing between two candidate parameter sets and want systematic evidence

Do not sweep if:

  • The base strategy has a negative Sharpe (fix the thesis first)
  • You've already iterated heavily on parameters in the same session (likely curve-fitting)

2. Requesting a parameter sweep

After a completed backtest, ask:

"Run a parameter sweep on the EMA period (range 10-50 in steps of 5) and the RSI threshold (range 55-75 in steps of 5). Show me the Sharpe heatmap."

Or for a single-dimension sweep:

"Sweep the ATR stop multiplier from 1.0 to 3.0 in steps of 0.25. Which setting gives the best Sharpe without sacrificing win rate?"

The Quant agent calls run_parameter_sweep and iterates across the specified grid, running a full backtest for each combination. The results appear as an interactive heatmap in the chat.

3. Reading the Sharpe heatmap

The heatmap axes are your two parameters; each cell is the Sharpe ratio for that parameter combination. A well-behaved strategy looks like a smooth ridge: a broad region of positive Sharpe that doesn't depend on a precise parameter value.

What to look for:

  • A broad ridge: the strategy works across a wide parameter range. Pick the center of the ridge, not the peak. This is your robust parameter set.
  • An isolated spike: one or two cells with very high Sharpe surrounded by poor cells. This is a classic overfitting signal. The spike is noise; avoid it.
  • Uniformly low Sharpe: the strategy doesn't work regardless of parameters. Go back to the thesis.
EMA period → 10 15 20 25 30 35 40 45 50 RSI ↓ 55 0.3 0.5 0.7 0.9 1.1 1.2 1.0 0.8 0.6 60 0.4 0.7 1.0 1.3 1.5 1.4 1.2 0.9 0.7 <- broad ridge 65 0.5 0.8 1.1 1.4 1.6 1.5 1.1 0.8 0.6 70 0.3 0.6 0.9 1.1 1.2 1.0 0.8 0.6 0.4 75 0.1 0.3 0.5 0.7 0.8 0.7 0.5 0.3 0.2

In this example, EMA=35/RSI=65 is the peak. But the ridge from EMA=25-40/RSI=60-65 shows similar Sharpe. Pick EMA=30/RSI=62, the center of the ridge. It won't be the optimal point in-sample, but it's more likely to hold out-of-sample.

4. The agent's auto-ranking

After the heatmap, the Quant agent automatically ranks the top parameter sets and highlights which ones sit on ridges vs spikes:

Rank EMA RSI Sharpe Ridge score Recommendation ────────────────────────────────────────────────────── 1 30 65 1.52 0.91 Broad ridge (recommended) 2 35 65 1.58 0.87 Broad ridge (safe) 3 35 60 1.55 0.83 Broad ridge (safe) 4 20 70 1.71 0.31 Isolated spike (avoid)

The ridge score measures how stable the Sharpe is in the neighbourhood of that parameter set. A high ridge score means small parameter changes don't collapse performance.

5. Validate the chosen parameters

After picking a robust parameter set from the sweep, don't stop there. Run a walk-forward test to confirm the parameters hold out-of-sample:

"Run a walk-forward test with 6 folds using EMA=30, RSI=65 on the same strategy."

If the out-of-sample Sharpe collapses compared to the in-sample Sharpe from the sweep, the parameters are still curve-fit. Try a wider parameter set or reconsider the thesis.

See Walk-Forward and Monte Carlo Validation for the full validation workflow.

6. One-dimensional sweeps for single parameters

For simpler strategies with one key parameter, a 1D sweep is often enough:

"Sweep the RSI period from 7 to 21 in steps of 2. Show me the Sharpe vs period chart."

The result is a line chart instead of a heatmap. The same principle applies: look for a flat plateau, not a sharp peak. If Sharpe is high at RSI=9 but low everywhere else, it's noise.

7. Sweeping stop-loss parameters

Stop-loss parameters interact with the strategy in non-obvious ways. A tight stop increases win frequency but reduces win size; a wide stop does the opposite. Sweep the stop alongside the signal parameter:

"Sweep the ATR stop multiplier (1.0 to 3.0) and the EMA period (20 to 50). Show the Sharpe and profit factor heatmaps side by side."

Look for parameter combinations where both Sharpe and profit factor are healthy, not just one. A high-Sharpe / low-profit-factor combination often means frequent small wins with occasional catastrophic losses.

Common mistakes to avoid

  • Sweeping too many parameters: every dimension you add multiplies the number of combinations and the chance of finding spurious peaks. Two parameters is the practical limit.
  • Picking the peak: always pick the ridge center, not the maximum cell.
  • Skipping walk-forward: a good sweep result is not a substitute for out-of-sample testing. It narrows the parameter space; walk-forward tests it.
  • Sweeping after many manual iterations: if you've already tuned the parameters by hand several times, sweeping the remaining space is double-dipping on in-sample data.