Run a sweep
Turn any rule into an axis and read the grid for plateaus rather than peaks.
A sweep runs the strategy loaded under Strategies once for every combination of the values you type, then shows the results side by side. It uses the same engine, fills and margin as a single backtest, described in Fills, costs and margin. Build the strategy first (see Build a strategy).
Run your first sweep
- Open
Sweeps. The strip at the top names the loaded strategy and the chain it will run against. - Under
Axes, edit the two starting axes or clickAdd axis. Each axis is a rule picked from the dropdown and a comma-separated list of values. - Click
Run 12 combinations. The number on the button is the product of the value counts on every axis, and it updates as you type. While the sweep runs the button readsRunning…. - Read the grid under
Results, then clickExport gridto save it as CSV.
A new window starts with two axes, profit target % at 25, 50 and 75 and stop loss % at 100, 150, 200 and 300, which is 12 combinations. Click Remove beside an axis to drop it. With no axes the button reads Run sweep and stays disabled until an axis is added. A grid of one cell reads Run 1 combination.
Axes and values
Any rule below can be an axis, once per sweep. A rule already used by another axis is greyed out in the dropdown, and leg strike can appear once per leg. Add axis picks the first unused rule and is disabled when none is left. The empty input shows an example list for the chosen rule. Values are typed one by one, so a sweep over 25 to 75 in steps of 5 is written out as 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75.
| Axis | Example | Notes |
|---|---|---|
entry DTE | 0, 1, 7 | Whole days to expiry at entry, 0 or more |
entry time | 09:35, 10:00, 11:00 | Eastern time as HH:MM |
profit target % | 25, 50, 75, off | Above 0, accepts off |
stop loss % | 100, 200, 300, off | Above 0, accepts off |
exit time | 15:00, 15:45, off | Eastern time as HH:MM, accepts off |
exit DTE | 0, 7, 21, off | Whole days, 0 or more, accepts off |
max days | 1, 3, 7, off | Whole days held, 0 or more, accepts off |
contracts | 1, 2, 5 | Whole numbers, 1 or more, switches sizing to a fixed count |
capital % | 2, 5, 10 | Above 0, switches sizing to a share of the account |
leg strike | 0.10, 0.16, 0.30 | Pick the leg, keeps that leg's selection mode |
- The words
off,noneand-switch a rule off for that cell. Only the five exit rules accept them. A position with every exit rule off runs to expiry. - Profit target and stop loss percentages are of the credit taken in or the debit paid out, the same as on the strategy form.
leg strikeadds a second dropdown to pick the leg. The values replace that leg's strike selection and keep its mode, so a leg selected by delta sweeps deltas, a leg set by % from spot sweeps offsets, and a leg set by strike price sweeps strikes. The result header names which, for exampleleg 1 delta.contractsandcapital %replace the strategy's sizing for each cell, whichever mode it was saved with.
Errors
- Each value is checked against the rule in the table above. A value that does not fit, such as
25%on a percentage,1.5on a day count or9:7xon a time, shows a message under the axis that names the bad values and what the axis takes, for examplecannot read 1.5, use whole numbers 0 or more, or off. The run button stays disabled until it is fixed. - An axis with no values shows
enter at least one valueand disables the run button. - An axis that repeats a rule already swept, for example from a saved default, shows
axis N already sweeps this ruleand disables the run button until one of the two is changed or removed. - With no strategy loaded the strip reads
No strategyand the run button is disabled. - A
leg strikeaxis pointing past the strategy's last leg stops the sweep withthe strategy has no leg N.
The 10,000 limit
A sweep runs at most 10,000 combinations. Above that the run button is disabled, it still shows the full count, and a message under the axes reads 12,000 combinations is over the 10,000 limit. The engine refuses the same grids with 12,000 combinations exceeds the 10,000 limit. Four axes of 10 values each is exactly 10,000 and runs. One more value on any of them is refused.
Parallel execution and data
Every combination runs against one shared copy of the chain, spread across all cores of the machine. Each cell is a full backtest with its own fills, commission and margin. The sweep is unmetered, so a wider grid costs nothing beyond the time to run it.
With a chain loaded under Data, the sweep runs on that chain, and the strip shows its Root, Window, Bars and Source. Contracts settle by the root's own convention. With nothing loaded the strip reads generated chain and the sweep runs on synthetic data, which is useful for checking a grid but says nothing about a real market. To load history, see Connect Databento or Connect ThetaData, and what the data costs.
A finished sweep stays in place when you switch to another tab and back. Running again replaces it.
Read the results
The dropdown above the results picks the metric. The choices are Total P&L, CAGR, Return on margin, Profit factor, Win rate and Max drawdown. Return on margin is total P&L divided by peak margin used. The run count sits beside the dropdown.
Heatmap
Exactly two axes draw a heatmap. The first axis runs down the rows and the second across the columns. Green is favourable and red is unfavourable, and the colour deepens with distance from the midpoint.
- P&L, CAGR and return on margin centre on 0. Profit factor centres on 1.
- Win rate and max drawdown have no natural midpoint, so they shade from the lowest value in the grid. For max drawdown, lower is better.
- A cell with no value for the metric shows a dash. Profit factor has no value in a run with no losing trade, and return on margin has none in a run that held no margin.
The legend under the grid gives the range the colours span. The best cell for the chosen metric is marked, and the line below the grid shows its axis values, trades, win rate, P&L, CAGR, max drawdown and profit factor. Hover any cell to show that run there instead. Table switches the heatmap to a list and Heatmap switches back.
Table
One axis, or three or more, lists the runs as a table with one column per axis followed by Trades, Win rate, Total P&L, CAGR, Max DD, Peak margin and Profit factor. The last axis varies fastest down the rows.
Plateaus, not peaks
The best cell is the one most likely to be noise. On any grid one combination wins, and with enough cells it wins by luck. A setting worth trading sits in a region where its neighbours also do well, so a small change in the market does not flip the result.
- Look for a block of similar colour rather than a single bright cell. A bright cell surrounded by red is a peak. A broad green patch is a plateau.
- Pick from the middle of the plateau, not its edge, even when the edge scores higher.
- Switch the metric. A region that stays green on P&L but turns red on
Max drawdownis paying for its return with risk. - Check the trade count in the detail line. A cell with few trades has little to say.
For the method behind this, see how to backtest options strategies and parameter sweeps.
Export the grid
Export grid opens the save dialog with sweep.csv as the name. The file has one row per cell, whether the screen shows a heatmap or a table. Each row starts with the axis values that produced it, headed by the axis labels, followed by the same statistics the summary export carries.
Stats columns are trades, wins, losses, win_rate_pct, total_pnl, final_equity, avg_win, avg_loss, profit_factor, max_drawdown, max_drawdown_pct, cagr_pct, max_margin_used, max_margin_pct and skipped_entries. A run with no losing trade leaves profit_factor empty. A switched-off rule exports as off.
After saving, the path appears beside the button. Cancelling the dialog writes nothing. The other exports are covered in Results and export.