Strategies we backtested Bollinger Band bounce

Tested by BacktestingMax

Bollinger Bands mean reversion strategy backtest

Does the Bollinger Bands mean reversion strategy make money?

Mostly no: it lost money in 27 of our 36 backtests. Bollinger Bands are an indicator with three lines: the middle band is the average closing price of the last 20 candles, and the upper and lower bands are drawn above and below it. Mean reversion is the idea that price tends to come back to its average after a big move. The Bollinger Bands mean reversion strategy, also called the Bollinger Band bounce, buys when price closes back above the lower band, sells short when price closes back below the upper band, and takes profit at the middle band. We tested it from 2014 to 2025, with trading costs, on 5 currency pairs, gold and 3 stock indices, each on 15-minute, 1-hour, 4-hour and daily charts. All 18 tests on 15-minute and 1-hour charts lost money. Price got back to the middle band in about half of the trades, but on average the winning trades made less than the losing trades lost. Only 3 tests made money in both 2014–2021 and the newer years, 2022–2025: EUR/USD, AUD/USD and the DAX, all on daily charts. They grew their accounts by only 5.6% to 11.9% in 12 years. The best test, the S&P 500 on 4-hour charts (+46.4%), lost money in 2022–2025.

36 backtests 2014–2025 Trading costs included Tested 12 October 2026

Where it worked 36 backtests
Made money
9
of 36 tests, using the standard rules
Made money in both periods
3
2014–2021 and again 2022–2025
Best backtest
+46%
S&P 500, 4-hour chart: account growth 2014–2025
With the take-profit at the opposite band
5
tests made money in both periods, compared with 3 using the standard rules

Made money in both periods

  • EUR/USD, daily
  • AUD/USD, daily
  • DAX, daily

Lost money on every market

  • 15-minute charts
  • 1-hour charts

The results

Results on every market

Each box shows one backtest of the Bollinger Band bounce using the standard rules, from 2014 to 2025, after trading costs: the % result, and a small chart of the account balance. The solid line is the account balance and the dashed line is the starting balance. Green results made money; red results lost money. Under each result: whether it made money in both 2014–2021 and 2022–2025, or passed all four of our checks (see "How a test passes" further down).

Market 15-minute 1-hour 4-hour daily
EUR/USD −100% Lost money. Account down 90% by Sept 2016 −74% Lost money −32% Lost money +6% Made money in both periods
GBP/USD −99% Lost money. Account down 90% by Nov 2015 −50% Lost money −35% Lost money +9% Made money overall, lost in one period
USD/JPY −100% Lost money. Account down 90% by May 2015 −97% Lost money. Account down 90% by Sept 2021 −50% Lost money −7% Lost money
AUD/USD −100% Lost money. Account down 90% by Oct 2015 −84% Lost money +42% Made money overall, lost in one period +6% Passed all four checks
EUR/GBP −100% Lost money. Account down 90% by Nov 2014 −97% Lost money. Account down 90% by Apr 2022 −29% Lost money +1% Made money overall, lost in one period
Gold −99% Lost money. Account down 90% by Jul 2015 −92% Lost money. Account down 90% by Nov 2022 −28% Lost money +3% Made money overall, lost in one period
S&P 500 −100% Lost money. Account down 90% by Dec 2015 −85% Lost money. Account down 90% by Sept 2022 +46% Made money overall, lost in one period −2% Lost money
Nasdaq 100 −100% Lost money. Account down 90% by Oct 2014 −94% Lost money. Account down 90% by Jan 2018 −26% Lost money +6% Made money overall, lost in one period
DAX −99% Lost money. Account down 90% by Dec 2017 −89% Lost money −43% Lost money +12% Passed all four checks
All the numbers, test by test
Market Chart Trades Win rate Profit factor Result Max drawdown 2014–2021 2022–2025 Monte Carlo drawdown Trading costs
EUR/USD 15-minute 8,531 51% 0.87 −99.6% −99.6% −99.5% −1.9% −99.7% $13,471
EUR/USD 1-hour 4,234 53% 0.93 −74.2% −77.8% −50.8% −47.6% −85.3% $9,143
EUR/USD 4-hour 1,001 49.3% 0.91 −31.6% −56.9% −48.8% +33.6% −52.2% $1,344
EUR/USD daily 170 54.1% 1.08 +5.8% −13.6% +4.1% +1.7% −16.0% $115
GBP/USD 15-minute 6,973 50.7% 0.83 −99.4% −99.5% −99.3% −17.3% −99.6% $12,988
GBP/USD 1-hour 4,244 54.2% 0.97 −50.3% −62.1% −30.4% −28.5% −76.4% $14,824
GBP/USD 4-hour 991 48.5% 0.91 −35.1% −37.1% −26.8% −11.3% −54.1% $1,545
GBP/USD daily 167 53.3% 1.11 +8.5% −9.8% +10.4% −1.7% −15.5% $127
USD/JPY 15-minute 5,424 50.4% 0.77 −99.6% −99.6% −99.6% −1.1% −99.7% $9,206
USD/JPY 1-hour 3,958 48.3% 0.80 −96.6% −96.8% −92.1% −57.5% −97.4% $3,942
USD/JPY 4-hour 985 48% 0.85 −50.1% −58.8% −45.2% −9.0% −61.4% $1,221
USD/JPY daily 167 48.5% 0.91 −7.1% −15.0% +6.4% −12.7% −20.5% $112
AUD/USD 15-minute 6,136 50.9% 0.85 −99.6% −99.7% −99.6% −3.6% −99.7% $14,238
AUD/USD 1-hour 4,046 52% 0.91 −84.2% −84.2% −73.2% −40.9% −90.1% $9,698
AUD/USD 4-hour 993 54% 1.08 +42.2% −27.7% −7.9% +54.4% −32.5% $2,970
AUD/USD daily 167 56.9% 1.08 +5.6% −10.5% +0.8% +4.8% −14.7% $158
EUR/GBP 15-minute 3,210 48.8% 0.65 −99.7% −99.7% −99.6% −15.5% −99.7% $11,700
EUR/GBP 1-hour 4,238 53.1% 0.84 −96.5% −96.7% −89.0% −67.7% −97.2% $9,314
EUR/GBP 4-hour 997 50.3% 0.93 −29.0% −43.4% −22.3% −8.7% −51.2% $3,054
EUR/GBP daily 158 55.7% 1.02 +1.0% −13.1% −10.1% +12.4% −15.8% $211
Gold 15-minute 3,756 51% 0.78 −99.2% −99.2% −99.2% 0.0% −99.3% $13,259
Gold 1-hour 3,296 51.4% 0.83 −92.1% −92.1% −86.2% −43.0% −93.8% $7,330
Gold 4-hour 964 49% 0.92 −27.5% −38.2% −29.6% +3.0% −49.0% $1,843
Gold daily 155 53.5% 1.04 +2.6% −9.1% +11.4% −7.9% −14.9% $145
S&P 500 15-minute 4,865 43.3% 0.87 −99.9% −99.9% −99.9% 0.0% −99.9% $27,544
S&P 500 1-hour 4,038 50.2% 0.88 −85.0% −91.6% −84.6% −2.4% −90.5% $9,166
S&P 500 4-hour 1,017 49.4% 1.07 +46.4% −17.6% +66.6% −12.1% −36.5% $2,953
S&P 500 daily 165 50.9% 0.98 −1.9% −17.8% +1.6% −3.4% −19.6% $150
Nasdaq 100 15-minute 2,643 42.6% 0.69 −99.8% −99.8% −99.8% 0.0% −99.9% $16,582
Nasdaq 100 1-hour 2,823 47% 0.78 −93.5% −93.8% −92.9% −8.8% −94.9% $8,307
Nasdaq 100 4-hour 1,005 46.2% 0.94 −25.9% −44.1% −34.8% +13.6% −52.5% $2,357
Nasdaq 100 daily 161 49.1% 1.08 +6.2% −14.3% +6.7% −0.4% −15.3% $160
DAX 15-minute 7,263 44.8% 0.91 −98.5% −98.6% −97.6% −37.0% −99.1% $13,712
DAX 1-hour 3,778 48.7% 0.88 −89.1% −89.8% −68.3% −65.6% −92.3% $3,453
DAX 4-hour 1,006 46.2% 0.87 −42.5% −50.5% −45.5% +5.5% −56.1% $640
DAX daily 168 54.8% 1.19 +11.9% −6.8% +5.9% +5.7% −12.0% $53

Profit factor is the money won divided by the money lost. Above 1 means the test made money. Max drawdown is the biggest fall from the highest balance. 2014–2021 and 2022–2025 show the result in each period on its own. Monte Carlo drawdown: we shuffled the trades into a random order 1,000 times; in 95% of those runs, the worst drawdown was this number or less. Result is the change in the account, with the risk of each trade set to 1% of the account at that time.

The account balance

The best test and the middle test

Best test S&P 500, 4-hour chart +46.4% from 2014 to 2025
Middle test (median): half of the 36 did better, half did worse USD/JPY, 4-hour chart −50.1% from 2014 to 2025

What we found

What the 36 backtests show

  1. Price got back to the middle band in about half of the trades, but the winners were smaller than the losers. On 1-hour, 4-hour and daily charts, 52.9% of the trades reached the middle band and made 0.79R on average (R is the money a trade risks: 1% of the account). The other 47.1% hit the stop-loss first and lost 0.98R on average, so the average trade lost 0.04R. A few trades reached the middle band and still lost a little, so the win rate in the table below (the share of trades that made money) is 50.7%. We leave out the 15-minute charts here, because those accounts lost most of their money early: 81% of their trades are from 2014 to 2017.

  2. The middle band usually moves toward the price while a trade is open, so the target comes closer. For the trades that reached the middle band, the middle band was on average 1.17 times as far away as the stop-loss (1.17R) when the trade opened. Those trades made 0.79R on average, about two-thirds of that distance. So when these trades opened, the target was further away than the stop-loss. But in the end, they made less than a trade that hit the stop-loss lost (see the comparison below).

  3. On 15-minute and 1-hour charts, the strategy lost money on all 18 tests. All 9 accounts on 15-minute charts were down 90% at some point: the first in October 2014, the last in December 2017. The tests kept running after that, with smaller trades. On a 15-minute chart, the stop-loss and the middle band are close to the entry price, so the trading cost is a big part of what each trade can win or lose. Before trading costs, the 15-minute trades made money on 8 of the 9 markets. So on those 8 markets, the trading costs turned a gain into a loss.

  4. Results got better as each candle covered more time, but even on daily charts the gains were small. On 4-hour charts, 2 of 9 tests made money: the S&P 500 (+46.4%, the best backtest) and AUD/USD (+42.2%). Neither of them made money in both 2014–2021 and 2022–2025. On daily charts, 7 of 9 tests made money, from +1.0% (EUR/GBP) to +11.9% (the DAX) in 12 years. 3 of these daily tests made money in both periods: EUR/USD, AUD/USD and the DAX. AUD/USD and the DAX also passed all four of our checks (see 'How a test passes' below), with 167 and 168 trades in 12 years. Our trading costs include the spread, but not the overnight fee (swap) that most brokers charge for holding a trade overnight. Half of the daily-chart trades stayed open for a week or more, so for them this fee matters.

  5. We also tried three changes traders often make: entering as soon as a candle closes outside a band, taking profit at the opposite band (the upper band for a buy, the lower band for a sell), and a stop-loss twice as far away (3 ATR instead of 1.5 ATR; ATR is how far price moves in an average candle). None of them made money on most tests (see the table below). With the stop-loss at 3 ATR, price reached the middle band in 3 trades out of 4 on 1-hour, 4-hour and daily charts. But the average winning trade fell from 0.83R to 0.39R, and some of the trades that reached the middle band still lost a little (see the note under the table). Taking profit at the opposite band cut the win rate on the same charts from 50.7% to 34.4%, but raised the average winning trade to 1.78R. That change helped most on 4-hour charts: 6 of 9 tests made money with it, compared with 2 of 9 with the standard rules.

The moving target

The middle band moved toward the price, so the target came closer

These numbers are for the standard rules on 1-hour, 4-hour and daily charts: 27 tests from 2014 to 2025. They cover the 23,855 trades that reached the middle band. 1R is the distance from the entry price to the stop-loss. It is also the money a trade risks.

How far the middle band was from the price when the trade opened
1.17R
on average
What these trades made, after trading costs
+0.79R
on average: about two-thirds of the distance to the middle band at the start
Trades where the middle band moved toward the entry price
90%
before the trade closed

The middle band is the average of the last 20 closing prices. After a buy signal, price is below that average. While price stays below the average, the average usually keeps falling toward price. After a sell signal, price is above the average, so the average usually keeps rising toward price. The trade closes at the next candle's open after a candle closes at or beyond the middle band, so the exit is often a little past the band.

The three changes

What each change did on 1-hour, 4-hour and daily charts

Each row is one version of the strategy: the standard rules, or one of the three changes explained under 'Can the Bollinger Band bounce be improved?' further down. Each row puts together all the trades of that version on 1-hour, 4-hour and daily charts: 27 tests from 2014 to 2025. The win rate is the share of trades that made money. Results are in R: 1R is the money a trade risks, 1% of the account at the time. For example, −0.044R means that the average trade lost 4.4% of the money it risked.

Version Win rate Average winning trade Average losing trade Average trade
Standard rules 50.7% +0.83R −0.94R −0.044R
With the entry on a close outside a band 45.4% +1.09R −0.98R −0.040R
With the take-profit at the opposite band 34.4% +1.78R −0.98R −0.032R
With the stop-loss twice as far away (3 ATR) 62.4% +0.39R −0.70R −0.019R

On 4-hour and daily charts alone, the average trade was a small loss with the standard rules (−0.014R) and a small gain with the take-profit at the opposite band (+0.014R). With the stop-loss at 3 ATR, about 1 trade in 8 reached the middle band but still lost a little, because by then the middle band had moved past the entry price. That is why, with this stop, the average losing trade is much smaller than 1R, and smaller than with the other versions.

The strategy

What the Bollinger Band bounce is

Bollinger Bands are an indicator made of three lines around the price. The middle band is the average closing price of the last 20 candles. The upper and lower bands are 2 standard deviations above and below the middle band. A standard deviation measures how far the last 20 closing prices are spread out around their average. So the bands move apart when price moves a lot (high volatility), and come closer together when price is quiet. Most candles close between the bands. Mean reversion is the idea that after a big move, price tends to come back to its average. This strategy, often called the Bollinger Band bounce, waits for price to close outside a band. Once price closes back inside the bands, it opens a trade that aims for the middle band.

Bollinger Bands
20 candles, 2 standard deviations, on closing prices (the standard settings)
Stop-loss
1.5 × ATR(14). ATR is how far price moves in an average candle, over the last 14 candles.
Take-profit
The middle band. When a candle closes at or beyond the middle band, the trade closes at the next candle's open.
Risk per trade
1% of the account

The rules we tested

  1. Buy when a candle closes back above the lower band: the candle before closed below the lower band, and this candle closes at or above it. We call this candle the signal candle. The trade opens at the next candle's open.
  2. Sell short when a candle closes back below the upper band: the candle before closed above the upper band, and this candle (the signal candle) closes at or below it. The trade opens at the next candle's open.
  3. Skip the signal if the signal candle already closed at or beyond the middle band, because price is already at the target.
  4. Close a buy when a candle closes at or above the middle band. Close a sell when a candle closes at or below the middle band. The trade closes at the next candle's open. The middle band changes with every new candle, so the target moves while the trade is open.
  5. ATR is an indicator of how far price moves in an average candle, measured over the last 14 candles. Put the stop-loss 1.5 times the signal candle's ATR below the signal candle's close for a buy, or above it for a sell. The stop-loss does not move. If price reaches it, the trade closes at the stop price, or at a worse price if price gaps past it (opens beyond it).
  6. Only one trade is open at a time: a signal that comes while a trade is open is ignored. After a stop-loss, wait for the next signal.
  7. Size every trade so that, if the stop-loss is hit, the trade loses 1% of the account. The position size is rounded down to a lot size the broker allows, so a trade can risk a little less than 1%.

The method

How we tested it

The test

Markets
EUR/USD, GBP/USD, USD/JPY, AUD/USD, EUR/GBP, Gold, S&P 500, Nasdaq 100 and DAX
Charts
15-minute, 1-hour, 4-hour and daily candles
Dates
January 2014 to December 2025
Account
$10,000, risking 1% of the account on each trade
Trading costs
Included. Every trade pays that market's normal trading cost: the spread, which is the gap between the buy price and the sell price.

How a test passes

We call a test passed only if it meets all four checks. A strategy can make money in one backtest and still fail one of these checks.

  • At least 100 trades. With fewer trades, a good result could be luck.
  • It made money from 2014 to 2021 and again from 2022 to 2025. This shows whether the strategy kept working in the newer years, not only in the older ones.
  • A profit factor (the money won divided by the money lost) of at least 1.2 from 2022 to 2025, after trading costs.
  • In 95% of 1,000 random shuffles of the trades, the account must not fall more than 30% from its highest point.

Improvements

Can the Bollinger Band bounce be improved?

We tried three changes traders often make to the Bollinger Band bounce, one at a time, on the same 36 tests. The first change is to the entry: buy or sell as soon as a candle closes outside a band, without waiting for price to close back inside the bands. The second change is to the exit: take profit at the opposite band instead of the middle band. The third change puts the stop-loss twice as far away. A change that you pick because it did best in some years will look good in those same years, even if part of that was luck. So we picked the best change using 2014–2021 only, by the number of tests that made money. Then we checked it on 2022–2025, years we did not use to pick it.

Version Made money 2014–2021years used to pick the best version Made money 2022–2025years not used to pick it Made money in both periods Passed all four checks
Standard rules The rules in 'The rules we tested' above, with nothing changed. 9 of 36middle test −47.1% 9 of 36middle test −3.5% 3 2
With the entry on a close outside a band Buy as soon as a candle closes below the lower band, if the candle before it did not close below the lower band. Sell short as soon as a candle closes above the upper band, if the candle before it did not close above the upper band. This version does not wait for price to close back inside the bands. The exit and the stop-loss are the same as in the standard rules. 8 of 36middle test −48.6% 11 of 36middle test −4.3% 1 1
With the take-profit at the opposite bandBest on 2014–2021 Close a buy when a candle closes at or above the upper band, and a sell when a candle closes at or below the lower band, instead of at the middle band. The entries and the stop-loss are the same as in the standard rules. 10 of 36middle test −50.7% 13 of 36middle test −4.8% 5 1
With the stop-loss twice as far away (3 ATR) Put the stop-loss 3 times the ATR away from the signal candle's close, instead of 1.5 times. Each trade still risks 1% of the account, so the position is half as big. The entries and the exit are the same as in the standard rules. 9 of 36middle test −21.1% 12 of 36middle test −2.5% 4 1

Only a little: none of the three changes made money on most tests. In 2014–2021, the years we used to pick, taking profit at the opposite band did best, but only one more test made money with it: 10 of 36, compared with 9 with the standard rules. In 2022–2025, the years we kept for the check, 13 of 36 made money with it, compared with 9 with the standard rules. 5 tests made money in both periods with it, compared with 3: GBP/USD, AUD/USD, the Nasdaq 100 and the DAX on 4-hour charts, and EUR/GBP on daily charts. Over the whole test, the gain came from 4-hour charts: 6 of 9 made money with it, compared with 2 of 9. On daily charts, 6 of 9 made money with it, compared with 7 of 9. In 2022–2025, the middle test (half of the 36 did better, half did worse) lost a little more with it: −4.8%, compared with −3.5%. It also lost money on all 18 tests on 15-minute and 1-hour charts. With the stop-loss at 3 ATR, the middle test lost the least in both periods (see the table): in 2014–2021, it lost 21.1%, compared with 47.1% with the standard rules. We did not pick the wider stop, because we pick by the number of tests that made money, not by the size of the loss.

Passed all four checks with the take-profit at the opposite band

  • EUR/GBP, daily

Questions

Questions traders ask

Does Bollinger Bands mean reversion work?

Mostly no: the strategy lost money in most of our tests. In our backtest from 2014 to 2025, with trading costs, the standard rules (buy when price closes back above the lower band, sell short when it closes back below the upper band, take profit at the middle band) made money in 9 of 36 tests: 9 markets, each on 15-minute, 1-hour, 4-hour and daily charts. All 18 tests on 15-minute and 1-hour charts lost money. Price got back to the middle band in about half of the trades, but on average the winning trades made less than the losing trades lost. Only 3 tests made money in both 2014–2021 and 2022–2025: EUR/USD, AUD/USD and the DAX, all on daily charts.

Should you buy when price touches the lower Bollinger Band?

No: in our test, entering right away made money in fewer tests than waiting. We did not test a touch of the band. We tested the closest rule: buy as soon as a candle closes below the lower band, instead of waiting for a candle to close back above it. For sells, the same test sold short as soon as a candle closed above the upper band. Entering right away made money in 7 of 36 tests, compared with 9 when waiting. Only 1 test made money in both 2014–2021 and 2022–2025, compared with 3. On 1-hour, 4-hour and daily charts, entering right away won less often (45.4% of trades, compared with 50.7%), but its winning trades were bigger (1.09R, compared with 0.83R; R is the money a trade risks). So the average trade was about the same as when waiting: a small loss.

Should you take profit at the middle band or at the opposite band?

In our test, the opposite band did a little better, because of 4-hour charts, but most tests still lost money. Taking profit at the opposite band (the upper band for a buy, the lower band for a sell) made money in 12 of 36 tests from 2014 to 2025, compared with 9 when taking profit at the middle band. 5 tests made money in both 2014–2021 and 2022–2025, compared with 3. On 4-hour charts, 6 of 9 tests made money, compared with 2 of 9. On daily charts, 6 of 9 made money, compared with 7 of 9. On 1-hour, 4-hour and daily charts, only 34.4% of the trades made money, but the winning trades made 1.78R on average (R is the money a trade risks). On 15-minute and 1-hour charts, it still lost money on all 18 tests.

What is the best timeframe for Bollinger Bands mean reversion?

In our test, daily charts made money most often, but the gains were small. With the standard rules, 7 of 9 daily tests made money, from +1.0% to +11.9% in 12 years, with 155 to 170 trades per market. On 4-hour charts, 2 of 9 tests made money, including the best backtest (the S&P 500, +46.4%), but neither of them made money in both 2014–2021 and 2022–2025. On 15-minute and 1-hour charts, none of the 18 tests made money. On charts where each candle covers less time, the stop-loss and the middle band are closer to the entry price, so the trading costs are a bigger part of every trade.

The strategy code we ran

This is the exact code from the BacktestingMax strategy engine. Paste it into the strategy editor in the app to run it on any market.

class BollingerBandsMeanReversion(Strategy):
    """Bollinger Bands mean reversion as most traders learn it, plus three changes traders make.
    Standard (all switches off): Bollinger Bands of 20 candles and 2 standard deviations, on
    closing prices. Buy when a candle closes back above the lower band (the candle before closed
    below it). Sell short when a candle closes back below the upper band (the candle before closed
    above it). Skip a signal whose candle already closed at or beyond the target. Close a buy
    when a candle closes at or above the middle band (the 20-candle average), and a sell when a
    candle closes at or below it; the exit fills at the next candle's open. A stop 1.5 x ATR(14)
    from the signal candle's close caps every trade, sized so the stop costs 1% of the account.
    One trade at a time: a signal while a trade is open is ignored.
    The changes, one at a time:
      touch_entry = 1   don't wait: buy as soon as a candle closes below the lower band (the
                        candle before closed inside the bands), sell as soon as one closes above
                        the upper band
      exit_band   = 1   take profit at the other band: close a buy when a candle closes at or
                        above the upper band, a sell when one closes at or below the lower band
      atr_mult    = 3   a stop twice as far away: 3 x ATR(14) instead of 1.5 x ATR(14)
    """
    params = {"bb_period": Param(type=int, default=20, min=5, max=200),
              "bb_std": Param(type=float, default=2.0, min=0.5, max=5.0),
              "atr_mult": Param(type=float, default=1.5, min=0.5, max=10.0),
              "touch_entry": Param(type=int, default=0, min=0, max=1),
              "exit_band": Param(type=int, default=0, min=0, max=1)}
    lookback = 50
    def init(self, ctx):
        self.bb = ctx.indicator("builtin:bollinger_bands", period=ctx.params.bb_period,
                                std=ctx.params.bb_std)
        self.atr = ctx.atr(period=14)
    def on_bar(self, ctx):
        p = ctx.params
        up0, up1 = self.bb.upper[0], self.bb.upper[1]
        lo0, lo1 = self.bb.lower[0], self.bb.lower[1]
        mid = self.bb.mid[0]
        a = self.atr.value
        if up0 is None or up1 is None or lo0 is None or lo1 is None or mid is None or a is None:
            return
        c0, c1 = ctx.close[0], ctx.close[1]
        # The target: the middle band, or the other band with exit_band.
        target_long = up0 if p.exit_band == 1 else mid
        target_short = lo0 if p.exit_band == 1 else mid
        pos = ctx.position
        if pos is not None:
            # The exit: a close at or beyond the target. It fills at the next candle's open.
            if pos.is_long and c0 >= target_long:
                ctx.close_position()
            elif pos.is_short and c0 <= target_short:
                ctx.close_position()
            return
        if p.touch_entry == 1:
            buy_signal = c1 >= lo1 and c0 < lo0     # closes below the lower band
            sell_signal = c1 <= up1 and c0 > up0    # closes above the upper band
        else:
            buy_signal = c1 < lo1 and c0 >= lo0     # closes back above the lower band
            sell_signal = c1 > up1 and c0 <= up0    # closes back below the upper band
        # A signal candle that already closed at or beyond the target leaves nothing to take.
        if ctx.gate("bb_buy_signal", buy_signal) and ctx.gate("target_above", c0 < target_long):
            stop = c0 - p.atr_mult * a
            ctx.buy(size=ctx.size_by_risk_pct(0.01, stop=stop, entry=c0), sl=stop, tag="bb_long")
        elif ctx.gate("bb_sell_signal", sell_signal) and ctx.gate("target_below", c0 > target_short):
            stop = c0 + p.atr_mult * a
            ctx.sell(size=ctx.size_by_risk_pct(0.01, stop=stop, entry=c0), sl=stop, tag="bb_short")

Your turn

Test the Bollinger Band bounce yourself

Change the settings, the market or the stop-loss and see the result in seconds. Ask the BacktestingMax AI: Backtest Bollinger Bands mean reversion on AUD/USD, 4-hour chart, taking profit at the opposite band.

Try it free in BacktestingMax

Free account. No credit card needed.

See every strategy we tested Browse strategies shared by traders

Backtest on historical data with trading costs, run by BacktestingMax. Past results do not guarantee future results, and nothing here is financial advice. Updated 12 October 2026.