Oisigma/Blog
Research & notes

How to Backtest a Band Indicator on Your Own Data

Every band drawn on a chart is making a claim: the next close should usually land inside it. Unusually for an indicator claim, it can be checked by anyone with a column of closing prices and a spreadsheet, without trusting a vendor's screenshot or a vendor's paper — including ours.

This article describes how such a test is built, where it silently goes wrong, and what number a fair test should be compared against. It is a procedure for measuring a band, not a way of trading one.

What a band backtest actually tests

The measurement is the containment rate: the fraction of bars on which the next close landed inside the band drawn before it. The containment test is what turns "which band is better?" from taste into measurement, and it is the only claim this article measures. It says nothing about direction, entries, exits or profit.

A useful test has four parts: a clean series of closes, a band built without peeking, a scoring rule applied bar by bar, and a benchmark to compare the result against. Most home tests get the first three roughly right and skip the fourth, which is where the result stops meaning anything.

The data: a series of closes, adjusted

The only input a close-based band needs is a series of closes on one symbol at one timeframe. TradingView offers a chart-data export on some plan tiers, and daily history can be downloaded from many public price sources; the working paper lists the feeds it used in its reproducibility appendix.

Two properties of the file matter more than its source. The closes should be adjusted for splits and, for equities, ideally for dividends: an unadjusted series contains a fake one-day return of several hundred percent at every split, and one such bar distorts the volatility estimate for the whole window that follows it. And the series needs a warm-up: a 60-bar window cannot produce a band until 60 returns exist, so the first 60 bars are consumed before scoring begins. A few years of daily data leaves plenty; a few months does not.

Building the band without looking ahead

This is the step that decides whether the test means anything, and it hinges on one lag.

A return-space band is a rolling mean and standard deviation of recent percentage returns, projected from the prior close; the spreadsheet mechanics of the rolling calculation are in what is rolling volatility. The band for a given bar must be computed from returns already known when that bar opened. In a spreadsheet, that means the window feeding the band on row t ends on row t − 1, and the band is anchored to the close on row t − 1. The close on row t is the thing being tested; it never enters the calculation that produces the band it is tested against.

The FAQ page states the published version of this rule: for each bar the band is constructed from information available at the prior close only, and the realized close is then classified as inside or outside. No lookahead.

The mistake is easy to make and almost invisible once made. A rolling function whose window includes the current row builds a band that already contains the close it is about to score, and the containment rate is flattered by exactly that leak. The fix is a single offset.

Scoring each bar

Once the band exists on every row after the warm-up, the score is a yes-or-no per row: did the close on row t sit between the lower and upper band computed from rows up to t − 1? A column of ones and zeros, averaged, is the containment rate.

Two details keep the test honest. The score uses the close, not the high or low, because a close-based band makes a claim about closes; a wick that pierced the band and a close that returned inside it is an inside observation. And every bar after the warm-up is scored — a band that only counts the bars it likes is not being tested.

What number to expect

A home test produces a percentage, and the temptation is to judge it by feel. The correct comparison depends on how the band was built.

A band placed one standard deviation either side of the mean is often assumed to target the textbook 68.27%. That figure applies when the mean and standard deviation are known exactly. A band built from 60 sample returns is estimating both, and the estimation error widens the correct target: under a Gaussian null the finite-window benchmark at n = 60 is 67.46% for a one-standard-deviation band and 94.80% for a two-standard-deviation band, as set out in the working paper. The gap is larger for shorter windows and shrinks as the window grows. A test scored against the textbook figure is measuring against a target the construction never promised.

For orientation, the working paper's result on this construction is that the inner band contained the next close about 71% of the time historically and the outer band about 94%, across the instruments tested; the tables are on the Proof page. Past behavior is not a guarantee of future results. The few points by which 71% exceeds 67.46% is the part of the number that carries information — the paper attributes it to the heavy-tailed shape of real returns — and it is visible only once the right benchmark is on the table.

The same logic applies to any band. A band built on price levels can be scored the same way; the Bollinger Bands® audit reports roughly 83% at the canonical (20, 2) setting against the ~95% its construction nominally implies, and a home test of that band would be expected to reproduce that gap.

Reading the result

A containment rate lands in one of three places relative to its benchmark. Well above it, the band is wider than its construction implies: reassuring to look at, uninformative when price touches it. Well below it, the band is narrower than advertised. Near the benchmark, with a modest excess of the kind fat tails produce, is what a calibrated band looks like.

One number from one stretch of one symbol is a weak reading, and two cheap extensions strengthen it: splitting the file in half and scoring each half separately, and running the same sheet on a second, unrelated symbol. The working paper did both at scale — an out-of-sample split on every instrument and a fresh set of 79 random names — and the cross-asset evidence reports what it found.

What a home test should not do is adjust the window until the number looks best and report that number. Every retry is a hidden parameter, and a result produced that way describes the search rather than the band.

Why a home result will differ slightly from the paper's

A reader who rebuilds this construction and lands a few tenths of a point away from the paper's figure has not found an error. Several small choices move a containment rate by fractions of a point, and the paper documents each: the standard-deviation divisor (n − 1 versus n shifts universe-mean coverage by about a third of a point), the vendor whose closes were used, how the series was adjusted, the start and end dates, and whether returns were computed as simple percentage changes, as the paper does, or as log returns. The reproducibility appendix lists the scripts, data sources and file hashes behind every published table so that a difference can be traced to a choice rather than argued about.

The takeaway

A band's central claim is checkable at home: adjusted closes, a band built from the window ending one bar earlier, a yes-or-no score per bar, and a comparison against the finite-window benchmark rather than the textbook figure. Done that way, the test says whether a band is too wide, too narrow or calibrated on the data in front of the tester. It does not say whether any use of the band makes money; the working paper validates the range's calibration, not the profitability of any way of using it, and whether any use delivers value after costs is an open question a containment rate cannot settle.

Frequently asked questions

How much historical data is needed to backtest a band? Enough to absorb the warm-up and still leave a sample whose confidence interval is narrow enough to read. A 60-bar window consumes the first 60 bars outright. Beyond that, the working paper's decade rows are a useful yardstick: roughly 2,500 daily bars per decade carried 95% intervals of about two to three points either side, historically, while the full 24,000-bar sample narrowed that to under a point. A few hundred bars will produce a number, but its interval will be too wide to distinguish calibrated from merely plausible; past behavior is not a guarantee of future results either way.

Can this be done in TradingView's Strategy Tester instead of a spreadsheet? Not directly. The Strategy Tester evaluates strategy scripts — rules that open and close positions — and reports trade statistics, not the fraction of closes inside a band. A containment count is a property of the band alone, with no trades involved, so it is computed either in a spreadsheet from exported data or in a script that logs an inside-or-outside flag per bar. The working paper's own tests were run in code on downloaded series, not inside a charting platform.

If a band scores well on containment, does a strategy built on it work? No, and the two questions are independent. Containment describes how often the next close historically landed inside a stated range; it carries no information about direction, and a rule layered on top of the band has its own settings, its own search and its own capacity to fit the past. The working paper validates the range's calibration only. Whether any use of a calibrated range delivers value after costs is an open question that a containment test does not address.

Can the paper's numbers be reproduced exactly? The intent is yes. The reproducibility appendix of the working paper maps every published table to a named replication script, records a hash and vendor reference for every input series, and notes the data-handling choices that affect the result; the scripts are available from the author on request, and the raw vendor data has to be re-obtained under the vendor's own terms. A home test that follows the construction described above without those exact inputs should land within a fraction of a point, for the reasons set out in the section on why results differ.

The fastest way to see what a calibrated range looks like before building the sheet is to watch one on a live chart. BTM draws a return-space expected range on any TradingView symbol, and you can start a free 30-day trial to compare the band you would be testing against the markets you already follow.

Now, your charts

Curious how this looks on your charts?

Try it free for 30 days and see the range update as new bars print, on whatever symbols and timeframes you actually trade.

Start your free trial
Complete checkout
Read the paper

30 days free, then $15/mo. Cancel anytime from your account.

Pick up where you left off.