Parameter sweeps that optimise on one period and check on the next
Strategy optimisation is easy to fool. Run enough settings and one of them will look excellent by chance. A Veloce sweep backtests every combination you ask for, ranks them by net P&L, and then reruns the best few on a later period they were never tuned on.
How a sweep runs
In the app a sweep runs as a job: you name the settings to vary, the check date and how many to check. Its result is stored with your other runs.
- 1
Choose the settings to vary
Give each setting a list of values, such as fast 3, 5 and 9 and slow 8, 13 and 21. Every other setting stays fixed.
- 2
Build every combination
Three values of fast and three of slow make nine backtests. The data is fetched once and shared by all of them.
- 3
Skip what the strategy rejects
A combination the strategy refuses, such as a fast average that is not faster than the slow one, is listed with its reason instead of run.
- 4
Rank by net P&L
Every run that completes is ranked by net P&L after charges, with its drawdown, trades, win rate, profit factor, fees and peak at risk beside it.
- 5
Rerun the best on a check period
The top three by default are run again from the day after the tuning period ends to the check date, on data none of them was chosen on.
Two periods, and a line between them
Best net P&L, tuning period
+₹18,420
Best settings
Fast 5, slow 13
Same settings, check period
−₹2,160
| # | Fast | Slow | Net P&L | Max drawdown | Trades | Win rate | Profit factor | Fees | Check net |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 5 | 13 | +₹18,420 | −₹9,310 | 142 | 42% | 1.21 | ₹9,842 | −₹2,160 |
| 2 | 3 | 13 | +₹15,975 | −₹11,880 | 188 | 39% | 1.15 | ₹13,030 | −₹5,410 |
| 3 | 5 | 8 | +₹11,240 | −₹8,650 | 176 | 40% | 1.12 | ₹12,195 | +₹1,385 |
| 4 | 9 | 21 | +₹6,830 | −₹7,420 | 98 | 41% | 1.10 | ₹6,790 | Not checked |
| 5 | 3 | 8 | −₹2,915 | −₹14,260 | 231 | 36% | 0.97 | ₹16,010 | Not checked |
| 6 | 9 | 13 | −₹4,480 | −₹12,730 | 121 | 37% | 0.94 | ₹8,385 | Not checked |
Why the best setting is often the luckiest one
In the illustrative sweep above, fast 5 and slow 13 ranks first on the tuning period with +₹18,420. On the check period it makes −₹2,160. The third-ranked setting, fast 5 and slow 8, made less in tuning, +₹11,240, and is the only one of the three that stays positive on the check period, at +₹1,385.
Across the three checked settings, tuning P&L adds up to +₹45,635 and check P&L to −₹6,185. That gap is the usual shape of overfitting: the more combinations a sweep tries, the more the winner’s result is inflated by chance, and the check period is where some of that inflation shows.
Signs a result is fitted, not found
- The best setting sits alone, with its neighbours far worse. Real effects tend to hold across nearby values.
- It has few trades, so a handful of lucky ones decide the ranking.
- Its win rate or profit factor collapses on the check period while its trade count stays the same.
- Fees take most of the gross profit, so a small change in fills would flip the sign.
What each measure tells you
- Net P&L
- Profit after every charge and the slippage on every fill. The ranking uses this alone.
- Max drawdown
- The largest fall in equity from a peak, in rupees.
- Trades
- Closed trades. A few trades make every other number noisy.
- Win rate
- The share of closed trades that made money.
- Profit factor
- Gross profit divided by gross loss, over closed trades.
- Fees
- Brokerage, taxes and exchange charges paid. A busier setting pays more.
- Peak at risk
- The most the open positions could have lost at expiry at any point, or unlimited when a position’s loss had no limit, such as an uncovered sold call or a sold future.
Parameter sweep questions
What is a parameter sweep in backtesting?
Running the same strategy many times with different settings, such as moving average lengths or stop distances, to see how the result depends on them. Veloce runs every combination of the values you give and ranks them by net P&L after charges.
What is a check period?
A stretch of time after the tuning period that the settings were not chosen on. Veloce reruns the best few settings on it, so you can see how much of their tuning-period result carries over to data they never saw.
Does a good check-period result mean the strategy will work?
No. It means the settings did not fall apart on one more stretch of history. A short check period can pass or fail by luck, and if you keep re-sweeping until the check period looks good, it stops being unseen data.
How many settings can I vary at once?
As many as the strategy has; each is given as a list of values and every combination runs. The number of runs is the product of the list lengths, so three settings with four values each is 64 backtests.
Can I export the sweep results?
Sweeps run as jobs in the app, and each result, with the tuning and check-period measures for every combination, is kept in your run history.
Sweep a strategy, then check it
Create an account with a verified email and phone number, pick a strategy and a market, and see every fill, fee and day of P&L.