Skip to content
TradingTune
TradingView Optimization

Why Range Versioning Matters

Explains how changes to boundaries, steps, and included inputs should be tracked across runs.

On this page

Key takeaways

  • A change to a boundary, a step, or an included input creates a new experiment, so each run needs a record of exactly what it tested.
  • The step size matters as much as the endpoints, because a coarser step can hide the region where a parameter stops generalizing.
  • A tighter, smoother result can come from quietly narrowing the range or dropping an input rather than from a setting that generalizes better.
  • A version tag is only useful when it is written before the run starts, not after the result looks interesting.

Why Tracking Parameter Range Changes Keeps a Sweep Honest

Range versioning means recording exactly which boundaries, step sizes, and included inputs produced a given optimization run, so that when you widen a range from one run to the next, you can tell whether a result changed because the market data changed or because you quietly changed what you were testing. The moment you nudge a lower bound, tighten a step, or drop an input from the sweep, you have created a new experiment, not a refinement of the old one, and if you do not log that change, the two runs become impossible to compare honestly.

I treat this as a discipline problem, not a tooling problem, though tooling helps. A parameter sweep is a set of runs where one or more strategy inputs, say a moving-average length or a channel width, are varied across a defined range and step, then each combination is backtested (a backtest replays a strategy against historical bars to see how its logic would have performed on that data) over the same window. Walk-forward testing splits that history into sequential in-sample and out-of-sample chunks so a setting is chosen on one stretch and checked on the next, unseen one, which is the closest a sweep gets to an honest test of whether a parameter choice generalizes beyond the data it was tuned on. When the range or the walk-forward split shifts between runs and nobody notes it, you lose the ability to say which factor moved the outcome. The Pine Script v6 user manual documents the input types and defaults that feed a sweep, and those defaults themselves are part of what needs versioning, since an unlogged change to a default input is still a change.

Three takeaways carry the rest of this post. First, a range change is a new dataset for comparison purposes, even if the strategy code never moved. Second, the step size matters as much as the endpoints, because a coarser step can hide the exact region where a parameter stops generalizing well to unseen data. Third, dropping or adding an included input changes the dimensionality of the whole sweep, not just one column of results. This is written for anyone iterating on a TradingView parameter sweep across multiple runs, whether you are exploring a single input or several at once, and want each run’s numbers to mean something when set against the last one.

Defining the Swept Parameters and the Walk-Forward Split

In my own sweeps I usually vary three kinds of inputs at once: a trend-following length, a volatility-based stop multiplier, and an entry threshold expressed as a percentage move. For the moving-average length I sweep values from 10 to 60 bars in steps of 5, which gives eleven data points and keeps each combination distinct without turning the run into an all-night grid. For the ATR-based stop multiplier (ATR, average true range, measures typical bar-to-bar volatility) I sweep from 1.0 to 3.5 in steps of 0.25, and for the entry threshold I sweep 0.5 percent to 3.0 percent in steps of 0.25 percent. Each of these inputs is declared in Pine Script (TradingView’s strategy scripting language) as an input.int or input.float with its own default, minimum, and maximum, and Pine Script’s input declarations carry the minimum, maximum, and step for each swept parameter, which is what the optimizer reads to build the sweep grid in the first place. The boundaries and the step size together decide how coarse or fine the resulting map of the parameter space will be, and I write all three down before I press run, not after I see the results and decide the range looked right in hindsight.

The walk-forward split I run alongside that sweep uses a 12-month in-sample window followed by a 3-month out-of-sample window, then rolls forward one month at a time across the full history. A good sweep must not let the walk-forward window drift silently between runs any more than the parameter range can drift silently; if the in-sample window grows from 12 months to 18 months at the same time the moving-average range widens, you have changed two variables at once and cannot attribute a shift in the out-of-sample picture to either one specifically.

When I ran the same length sweep twice, three weeks apart, with the lower bound moved from 10 to 8 and nothing else touched, the shape of the results near the old boundary shifted enough that I initially assumed something had broken in the optimizer. It had not. I had simply exposed two additional combinations that the first run never tested, and once I tagged the second run with its own range identifier the discrepancy stopped looking like a bug and started looking like exactly what a wider range should produce. That is the whole reason a version tag exists: it lets me look at two result sets side by side and know, before comparing a single number, whether I am looking at the same experiment run twice or two different experiments that happen to share a strategy name.

A version tag on a range does not need to be elaborate to do its job. Recording the parameter name, its lower and upper bound, its step size, and the walk-forward window length as a short string attached to the run’s output is enough to answer the only question that matters later: did this run test the same thing as the one I am comparing it to. Skip that tag and every shift you see across runs becomes a guess about which change caused it, which defeats the purpose of running a structured sweep in the first place.

TradingTune for Chrome

Stop tuning your strategy's inputs by hand.

Add to Chrome, it's free

Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.

How Sweep Behavior Shifts When a Range Boundary Moves

Widen a boundary and the shape of the sweep does not just gain new points at the edge, it can redraw the whole picture you thought you understood. The first observation I keep coming back to is what happens at the low end of a range: values near the floor tend to behave erratically from one bar count to the next, since a short length reacts to almost every wiggle in price and the resulting cycle results swing hard between neighboring settings. Push the lower bound down further, say from ten bars to six or seven, and you expose a stretch of the range where the curve looks jagged rather than smooth, not because the market changed but because you are now sampling a region the earlier run never touched. Anyone comparing the new run against the old one, without knowing the floor moved, would reasonably conclude the strategy had become unstable, when the truth is simpler: the sweep is unstable there, and it always was, you just had not looked before.

The second, distinct observation sits at the opposite end. Widen the upper bound and the cycle results generally flatten out, because a longer length smooths through more history and the differences between adjacent settings shrink. A parameter that once looked meaningfully different at each step starts to blur into its neighbors, and the practical effect is that the sweep tells you less per additional combination even as it costs more compute to run.

Step size changes produce a third kind of shift that is easy to miss because it does not touch the boundaries at all. Coarsen a step from five bars to ten and you are not just running fewer combinations, you are choosing not to look at the exact region where a parameter might flip from generalizing well to overfitting the in-sample window. I noticed this directly when I halved a step size on the entry-threshold sweep partway through a project: the coarser earlier run had missed a narrow band where the walk-forward split’s out-of-sample behavior diverged sharply from what the wider step suggested, and only the finer step revealed that the smooth-looking region was actually two distinct regions sitting close together.

Put all three shifts side by side and the core problem becomes obvious: a sweep’s shape is a function of the boundaries and the step, not an intrinsic property of the strategy. If you cannot say which boundary or step produced a given curve, you cannot tell an actual behavioral change in the parameter space from an artifact of sampling it differently. That is not a subtle distinction to a reader trying to learn from your results; it is the difference between a reproducible observation and a coincidence that happened to look like one.

A Versioned Range Log for the Smart Momentum Grid

Once you accept that a range change makes a new experiment, the natural next step is writing that experiment down as it happens, not reconstructing it later from memory. I keep a simple log for the Smart Momentum Grid (the founder’s own private strategy, shown here purely to illustrate the workflow) that records the parameter, its bounds, its step, which inputs were included, and the resulting cycle count for every sweep I run. The cycle count matters because it is the fastest sanity check that a range change actually landed: if I widen a bound and the cycle count for that parameter does not move, either the widened bound fell outside the input’s declared minimum or maximum, or I mistyped something, and I want to catch that before I spend an evening reading a sweep that never ran the combinations I thought it did.

The following table is hypothetical, the founder’s own Smart Momentum Grid, historical and illustrative only.

Parameter Range Step Cycle count
MA length v1 10 to 60 5 11
MA length v2 8 to 60 5 12
MA length v3 8 to 60 2 27
ATR stop multiplier v1 1.0 to 3.5 0.25 11
ATR stop multiplier v2 1.0 to 4.5 0.25 15
Entry threshold v1 0.5 to 3.0 0.25 11
Entry threshold v2 0.5 to 3.0 0.10 26

Read down the MA length rows and the version identity is doing more work than the numbers themselves. Version 1 and version 2 differ by a single point on the lower bound, yet that one point adds a full extra combination to the cycle count, and anyone who only glances at “8 to 60” without noticing the prior run said “10 to 60” would misattribute any shift near the floor to the strategy rather than to the wider net being cast. Version 3 holds the same bounds as version 2 but more than doubles the cycle count by halving the step, which is exactly the kind of change that leaves the range description looking almost unchanged in a casual summary while the underlying sweep is a materially different, much finer-grained experiment. The ATR stop multiplier rows tell a similar story from the other direction: extending the upper bound from 3.5 to 4.5 without touching the step adds four cycles at the coarse end of the range, precisely where I noted the results tend to flatten, so that version’s extra cycles are cheap to run but say comparatively little on their own.

The rows I would probe further are the two entry-threshold versions, because a step change from 0.25 to 0.10 percent on the same bounds is the largest jump in resolution in the whole log, which is exactly the comparison this table is set up to invite. Looking at cycle count alone would tell you version 2 of that parameter ran more than twice as many combinations as version 1, but only the paired range-and-step columns tell you why that jump happened and whether the extra resolution landed where it mattered. That is the practical argument for logging the full row rather than a single summary number: the cycle count without the range and step next to it is a count of something, but you cannot say of what.

When an Unversioned Range Change Creates an Overfit Illusion

The most instructive failure I have run into did not come from a bug in the strategy, it came from a range boundary I narrowed on purpose and then forgot to write down. I had been sweeping the moving-average length from 8 to 60 bars in steps of 2, and the region near the floor kept producing jagged, inconsistent cycle results, the kind of erratic behavior I had already flagged as a low-end artifact rather than a real signal about the strategy. To get a cleaner picture for a client walkthrough, I quietly moved the lower bound up to 15 for that one run, reasoning that I already understood the excluded region and did not need to re-run it. The resulting sweep looked smooth and convergent in-sample: cycle results near the middle of the range clustered tightly, and the whole shape read as a stable, well-behaved parameter neighborhood. It was not. It was a stable-looking picture of exactly the region I had chosen to keep, with the noisy part removed from view rather than resolved.

The second version of this same mistake involves dropping an included input rather than moving a boundary. On one project I fixed the ATR stop multiplier at a single value partway through a sweep, intending to isolate the moving-average length and entry threshold for a cleaner two-dimensional grid. What I got back looked like convergence, a narrow band of length and threshold combinations that agreed with each other more tightly than the earlier three-input sweep ever had. But that agreement was not evidence the strategy had become more robust; it was the mechanical consequence of removing a whole axis of variation. Fixing the stop multiplier had quietly collapsed the search space, and a walk-forward check across the held-out months showed the tight in-sample band did not survive contact with the next few weeks of data, because the excluded dimension had been doing real work in the earlier, wider sweep. Backtest overfitting from an unlogged reduction in the search space is exactly the mechanism formal work on overfit backtests describes: a result that looks robust in-sample can be nothing more than an artifact of how the search itself was constrained.

What fooled me both times was the same visual cue: a smoother, tighter-looking result reads as more trustworthy, and nothing in the output flags that the smoothness came from excluding data rather than from the strategy generalizing better. Out-of-sample testing exists precisely to catch this, since parameters chosen on one stretch of history are only meaningful once checked against a separate, unseen stretch, and a range change that happens between the in-sample tuning run and the out-of-sample check quietly breaks that separation.

The fix I now use is mechanical rather than a promise to remember better next time: every sweep carries a range-version tag alongside the swept inputs themselves, written directly into the script so it cannot be separated from the run that produced it. Pine Script’s input declarations are the natural place to attach that tag since they already carry the minimum, maximum, and step for each swept parameter.

Range Version Tag. This snippet tags each optimization run with a range-version string alongside the swept moving-average length so a chart label shows exactly which range configuration produced the plotted value.

Pine v6
//@version=6
indicator("Range Version Tag", overlay=false)
rangeVersion = input.string("v3", title="Range Version Tag")
lenMin = input.int(8, title="Length Min")
lenMax = input.int(60, title="Length Max")
lenStep = input.int(2, title="Length Step")
length = input.int(20, title="MA Length", minval=lenMin, maxval=lenMax, step=lenStep)
maValue = ta.sma(close, length)
var label tag = na
if barstate.islast
label.delete(tag)
tag := label.new(bar_index, maValue, text=rangeVersion + " len:" + str.tostring(length))
plot(maValue, title="MA")

That tag turns a silent boundary shrink or a dropped input into something visible on the chart itself, which is the only place I trust a range description not to drift away from the run it actually describes.

Applying Range Versioning to Your Own Sweep

My take is that a version tag is worthless unless it gets written before the run starts, not after you like what the run produced. The temptation is always to sweep first and document the winner, but by the time a result looks interesting you have already lost the discipline that made it trustworthy in the first place. I recommend treating the range declaration as part of the experiment design, not as a caption you add once the chart looks clean, because a caption written after the fact tends to describe the range you wish you had used rather than the one you actually ran.

The concrete next step is short enough to do before your next sweep and not after it. Write down, for every swept input, its lower bound, upper bound, step size, and whether it is included in this run at all, alongside the walk-forward window length, as one line attached to the run’s output before you press start. If you change any single one of those five things on the next run, give it a new version label rather than editing the old one in place, so a prior run’s row never silently becomes a different experiment under the same name. I prefer this over any fancier versioning scheme because it survives being done under time pressure at eleven at night, when a more elaborate process gets skipped entirely. My working rule is that if a range, step, or included-input list cannot be read off the run’s own output without asking me to remember it, the run has not been logged, it has only been performed. None of this tells you what setting to trade; it tells you whether the next comparison you make is honest, which is the only claim a versioned sweep is entitled to make.

Range Versioning as a Habit, Not a One-Time Task

The method this post has walked through is not complicated, but it only works if it is applied every time, not just when a run happens to matter. A boundary, a step, and the set of included inputs together define what a sweep actually tested, and none of those three facts survives in your memory as reliably as it survives in a one-line tag attached to the run’s own output. Whether you are widening a lower bound because the floor looked noisy, coarsening a step to save compute, or dropping an input to isolate a cleaner grid, you are choosing a new experiment, and the only honest way to treat it as new is to name it as new. The version log, the chart-side tag, the walk-forward window recorded alongside the range, none of these are ceremony; they are the minimum record that lets a future comparison mean something rather than just look plausible.

That matters because the alternative, comparing two runs without knowing whether their ranges matched, produces conclusions that only look like conclusions. A tighter, smoother result can come from a setting choices generalizing better to unseen data, or it can come from quietly narrowing the range or dropping a dimension of the search, and without a version tag those two explanations are indistinguishable from the outside. Out-of-sample testing is built to guard against exactly this, since a parameter chosen on one stretch of history only means something once checked against a separate, unseen stretch, and that guard is only as strong as the record of what range and split produced each side of the check. Go back to the question this post opened with, whether a shift in a sweep’s shape reflects the market or reflects a quiet change to what you were testing: the answer is never in the numbers themselves, it is in whatever you wrote down, or failed to write down, before you pressed run. Log the range, the step, the included inputs, and the walk-forward window every single time, and the habit costs you almost nothing next to what it saves you from believing.

Sources

TradingTune for Chrome

Stop tuning your strategy's inputs by hand.

TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.

Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.

Share this post