Bollinger Bands BacktestNovember 1, 202615 min read

Bollinger Bands Backtest: How to Test It Properly

How to backtest a Bollinger Bands strategy: define entries and exits, set costs, read the metrics, avoid overfitting, and validate before risking capital.

Bollinger Bands Backtest: How to Test It Properly

To backtest a Bollinger Bands strategy, write down exact rules (band settings, what counts as an entry, where you exit, how much you risk), run them on historical data with realistic costs, and judge the result on win rate, profit factor, and maximum drawdown across several markets and periods. Published research is a warning: a plain Bollinger rule rarely survives costs and new market conditions, so the test matters more than the indicator.

This guide walks through the full process, from rules to validation, with the mistakes that make a Bollinger backtest look better than it really is.

TL;DR

  • Use the standard setup, a 20-period average with bands two standard deviations away, as your baseline before changing anything.
  • Define entries on a close, not a touch. A rule you cannot state in one sentence cannot be tested.
  • Include commissions, spreads, and slippage, then judge win rate together with profit factor and maximum drawdown.
  • Hold back out-of-sample data, test on more than one market, and forward test before real money.
  • Independent studies of simple Bollinger rules found mostly weak or negative results, so treat your own result with suspicion until it holds up outside the data you tuned it on.

Table of Contents

What a Bollinger Bands backtest actually tests

A Bollinger Band is a moving average with an upper and lower band placed a chosen number of price standard deviations above and below it, as Charles Schwab explains. The common configuration is a 20-period average with bands two standard deviations away, though both numbers can be changed.

The bands widen when volatility rises and narrow when it falls. John Bollinger's own site says the indicator answers a relative question: whether price is high or low compared with its recent range, with the upper band marking relatively high and the lower band relatively low. MathWorks describes the same idea: a volatility measure that can flag potentially overbought or oversold conditions.

Notice what the indicator does not do. It describes where price sits, not where it will go. The Corporate Finance Institute points out that it is a lagging, reactive tool that does not predict future prices. And Fidelity notes that the bands are not meant to be used in isolation, so confirmation from other signals is part of many real-world setups.

That is why a backtest is the right tool. The bands give you a description. Your rules turn that description into a trade, and only historical data can tell you whether those trades made money.

What a Bollinger Bands backtest actually tests

Two strategy families worth testing

Most Bollinger systems fall into one of two camps, and they make opposite bets.

Mean reversion (reversal). Price outside a band is treated as stretched, so you fade it: buy after price falls below the lower band and returns inside, sell or short after the reverse at the upper band. The usual exit is the middle band.

Breakout (momentum). Price closing outside a band is treated as a sign of strength, so you trade in its direction. This is often paired with a squeeze, where the bands narrow and then expand.

These two ideas contradict each other, which is useful. If both "win" on the same data, one of them is probably fitting noise. Test them separately, on the same instruments and periods, and see which one, if either, holds up.

Comparison of reversal and breakout rules

Step 1: Write rules a computer could follow

A backtest is only as good as its rules. Vague rules like "buy when price looks oversold" cannot be replayed. A detailed Bollinger backtesting guide lists what to fix before testing: indicator settings, entry and exit signals, stop-loss method, position sizing, and transaction costs.

Here is a complete example for a reversal strategy:

  1. Settings: 20-period simple moving average, bands at 2 standard deviations, daily candles.
  2. Entry (long): a candle closes below the lower band, and the next candle closes back inside it. Enter at the next open.
  3. Exit: close at the middle band, or at the stop, whichever comes first.
  4. Stop: a fixed multiple of recent average true range below the entry.
  5. Size: risk the same fraction of the account on every trade.
  6. Costs: a commission and spread appropriate to the market.

The point about closes matters. The Right Trader defines the classic entry as the close back inside the band after a penetration, not the first touch. Testing on a touch assumes you could have known, in the middle of a candle, that it would be a signal. Often the candle then keeps going and never closes back inside. That single choice can swing a result from a loss to a profit on paper.

If you would rather type your rules in plain English than code them, Backtestify takes a strategy written in words and replays it on real historical market data, so the rule definition and the test live in one place. Our step-by-step backtesting guide covers the general workflow.

Step 2: Choose markets, timeframes, and history

The default 20 and 2 is your baseline. Resist the urge to hunt for better numbers on your first run. If the baseline shows nothing, a tuned version usually just shows the noise it was tuned to.

A few practical choices:

  • More than one instrument. A rule that works on a single stock may reflect that stock's trend. Test across several tickers or pairs, ideally from different sectors or asset classes. John Bollinger's site says the bands can be applied across equities, forex, commodities, and futures, which also means each has to be checked on its own.
  • More than one regime. Include a trending stretch, a choppy range, and a sharp sell-off. Reversal rules tend to look great in ranges and fall apart in strong trends, while breakouts do the opposite.
  • Enough trades. Retail guides sometimes suggest one to two years of major currency-pair data as a representative sample. Treat that as a minimum. On a daily chart, two years may give you only a few dozen signals, which is too few to separate skill from luck.
  • Timeframe consistency. Decide the timeframe before looking at results. Switching from daily to hourly because the daily run looked bad is a form of data mining.

If you swing trade, our swing trading backtest checklist shows how a false edge sneaks in at this stage.

Step 3: Model costs and fills honestly

Bollinger reversal systems trade often, and frequent trading is where costs do their damage. The guide above says to include brokerage fees, exchange charges, bid-ask spreads, taxes, and slippage, because these costs can erase theoretical profits, especially in high-frequency approaches.

Fill assumptions matter as well. On intraday charts, bar data hides what happened inside each bar. One practitioner guide recommends tick data or conservative worst-case fills to see how execution changes the result. If your stop and target both sit inside one candle's range, a careless backtest may assume the target was hit first. A conservative one assumes the stop was.

Stop distance also drives position size. Tying the stop to volatility keeps risk per trade consistent, and this practical ATR stop-loss walkthrough shows worked defaults and how to turn a stop distance into a position size. In a Bollinger test, that keeps a wide-band, high-volatility trade from risking far more than a narrow-band one.

A sensible habit is to run the test three times: with zero costs, with realistic costs, and with costs 50 percent worse. A strategy that only works in the first run is not a strategy.

Step 4: Read the numbers

A backtest produces a long list of figures. A handful do most of the work.

MetricWhat it tells youWhat to watch for
Win rateShare of trades that made moneyHigh win rates can hide a few large losses
Profit factorGross profit divided by gross lossNear 1.0 means costs or luck can flip it
Maximum drawdownLargest peak-to-trough fall in equityCan you actually sit through it?
ExpectancyAverage result per tradeNear zero means no edge
Number of tradesSample sizeSmall samples mislead

One retail guide suggests a viable strategy should combine a win rate above 50 percent with a positive profit factor. That is a rough filter, not a guarantee, and win rate alone is a poor judge: a reversal system can win 70 percent of the time and still lose money if the losers are three times the size of the winners. Another practitioner guide lists red flags for a failed backtest: a profit factor below 1.2, expectancy near zero, or single losses beyond the planned risk budget.

Look at how the equity curve gets there, too. A steady climb with shallow dips is a different animal from one huge winner carrying the whole result. Remove the best trade and check what is left.

What published research suggests

Before believing your own backtest, it helps to know how simple Bollinger rules have fared in formal research.

A 2018 doctoral dissertation applied a Bollinger Band strategy to tick-level EUR/USD data from 2009 to 2016 and found an overall net loss, concluding the strategy did not increase net gains. A separate study of high-frequency Chinese index futures from 2012 to 2016 found that 24 of 72 stationary Bollinger Band strategies were profitable, and only one had a win rate above 50 percent.

These are specific markets and periods, so they do not prove Bollinger Bands never work. They do show two things. First, a plain band rule is not a free edge. Second, a profitable result can coexist with a low win rate, which is why you judge payoff size together with win rate.

The practical lesson: treat the bands as a component. Add a trend filter, a volatility filter, or a confirmation signal, test each addition separately, and keep only the ones that improve results out of sample.

Biases that make a Bollinger backtest misleading

These are the usual culprits, roughly in order of how often they bite.

Curve fitting. Trying 15, 18, 20, 22, and 25 periods with 1.5, 2, and 2.5 deviations, then picking the best combination, tells you which settings fit the past. It says little about the future. The detailed backtesting guide names over-optimizing parameters to past data as a leading cause of inflated results.

Touch versus close. As covered above, testing on intrabar touches gives you signals you could not have acted on in time.

Ignoring regimes. A market that trended for three years and then went sideways will break a rule built on the first stretch. Check results year by year, not just in total.

Survivorship and selection. Testing only stocks that exist and thrive today leaves out the ones that collapsed, which are exactly the ones a reversal rule would have kept buying.

Cherry-picked examples. A chart with five perfect signals is a story, not a test. Count every signal, including the ugly ones.

For a deeper look at the overfitting problem, see our article on walk-forward analysis, which splits data into repeated train and test windows so that settings are always judged on data they have not seen.

Step 5: Validate before you trade real money

A good in-sample result is where validation starts. A sensible sequence:

  1. Hold out data. Build the rules on one period, then run them once on a later period you never touched. If performance collapses, the first result was fitted.
  2. Change the market. Run the unchanged rules on other instruments. Some decay is normal. A complete reversal is not.
  3. Stress the settings. Nudge the period and deviation slightly. If 20 works and 19 and 21 lose money, the edge is fragile.
  4. Walk forward. Repeat the build-then-test cycle across rolling windows.
  5. Forward test. One practitioner guide recommends a 30 to 90 day demo run to confirm that costs, fills, and risk rules behave as expected in real time. Our guide to forward testing lists five checks that make those results auditable.

Only after that should real capital come in, and at small size. The aim is to find out cheaply whether the strategy is as good as the test said.

Run the test on Backtestify

Backtestify is built for this workflow. You describe a strategy in plain English, such as a close back inside the lower band with an exit at the middle band, and it runs it on real historical market data and reports win rate, profit factor, and maximum drawdown trade by trade. Our methodology page explains how a strategy is simulated. You can also improve the rules and compare the original and improved versions side by side on recent data, then export the result in TradingView Pine Script format.

The Free plan lets you start without a published price, and the Pro plan is $29 per month or $190 per year for unlimited backtesting, improvement, and forecasting. See the pricing page for details.

Backtestify

If you want to see what a finished report looks like before you run your own, open one of the shared backtest reports or browse the published strategy library, where results are shown for winners and losers alike.

A short checklist before you trust the result

  • Settings fixed before looking at results, starting with 20 and 2.
  • Entries defined on closes, not touches.
  • Commissions, spreads, and slippage included, and a harsher cost case tested.
  • At least several dozen trades, across more than one market and regime.
  • Profit factor, drawdown, and expectancy reviewed, not win rate alone.
  • Out-of-sample and walk-forward results consistent with the first run.
  • A forward test completed before sizing up.

FAQ

What are the best Bollinger Bands settings to backtest?

Start with the standard 20-period average and two standard deviations, which is the most commonly used configuration. Then test small changes only to see whether results hold, not to pick the single best number. If a tiny change flips the outcome, the edge is fragile.

Does a Bollinger Bands strategy actually make money?

It depends on the market, the rules, and the costs. A 2018 dissertation on tick-level EUR/USD data found a net loss, and a study of Chinese index futures found only a minority of band strategies were profitable. Backtest your exact rules with realistic costs rather than relying on general claims.

Should I test a breakout or a reversal strategy?

Test both on the same data, because they bet in opposite directions. Reversal rules tend to suit ranging markets and breakout rules trending ones. Whichever holds up across instruments and out-of-sample periods is the one worth forward testing.

How much historical data do I need?

Enough to produce a meaningful number of trades across different market conditions. Some guides cite one to two years as a minimum sample, but several years across a trend, a range, and a sell-off gives a more honest picture. Always keep a later period untouched for validation.

Can I backtest Bollinger Bands without coding?

Yes. Backtestify lets you enter the strategy in plain English and runs it on real historical data, returning the trade list and key metrics. You can then export the result as TradingView Pine Script if you want to view it on a chart.

Sources