The Mega Backtrader Strategy Pack includes 500+ Backtrader-ready strategies, batch runners, dashboards, metrics, and chart exports. Get the complete package here: Mega Backtrader Strategy Pack.
ADX_ADXR_BBPct_Strategy combines trend strength with
price location inside—or beyond—a Bollinger Band envelope. It looks for
extreme price readings when ADX and ADXR confirm that the market is
moving decisively.
On UNH daily data from August 5, 2024 through August 4, 2026, the strategy returned 53.88% while UNH buy-and-hold lost 28.20%. Maximum drawdown was only 8.58%.
Strategy equity was ahead of buy-and-hold on 90.9% of days after day 30. It also won 81.3% of 126-day rolling comparisons and 90.0% of 252-day comparisons.
| Result | Value |
|---|---|
| Strategy return | 53.88% |
| UNH buy-and-hold return | -28.20% |
| Excess return | 82.08% |
| Final portfolio value | $15,388.30 |
| Sharpe ratio | 1.35 |
| Maximum drawdown | 8.58% |
| Closed / open trades | 11 / 0 |
| Win rate | 36.36% |
| Cumulative days ahead after day 30 | 90.9% |
| 126-day rolling windows ahead | 81.3% |
ADX measures trend strength without choosing a direction. ADXR smooths ADX through time. Bollinger %B measures price location relative to the bands: values below zero are under the lower band, while values above one are over the upper band.
self.adx = bt.indicators.ADX(
self.datas[0],
period=14,
movav=bt.indicators.SMMA,
)
self.adxr = bt.indicators.ADXR(
self.datas[0],
period=14,
movav=bt.indicators.SMMA,
)
self.bb_pct = bt.indicators.BollingerBandsPct(
self.datas[0],
period=20,
devfactor=2.0,
movav=bt.indicators.SMA,
)The strategy enters long when trend strength is high and price is below the lower band. It enters short when the same trend-strength filter accompanies price above the upper band:
if adx > 25 and adxr > 20 and pctb < 0:
self.entry_order = self.buy()
elif adx > 25 and adxr > 20 and pctb > 1:
self.entry_order = self.sell()This is an unusual combination: it fades an extreme price reading, but only in a strong-trend environment. Exits occur when ADX falls below 20 or price reaches the opposite Bollinger extreme.
Each entry receives a fixed stop 2% from its fill price. The order callback tracks entry and stop references separately and cancels orphaned protection when the position becomes flat:
if self.position.size > 0:
stop_price = fill_price * (
1.0 - self.p.stop_loss_pct / 100.0
)
self.stop_loss_order = self.sell(
exectype=bt.Order.Stop,
price=stop_price,
size=self.position.size,
)That explicit separation matters. It prevents an exit fill from automatically creating a new opposite order—a flaw found in several weaker strategy implementations.
| Setting | Value |
|---|---|
| Asset and benchmark | UNH |
| Period | 2 years |
| Interval | 1 day |
| Starting cash | $10,000.00 |
| Commission | 0.10% |
| ADX / ADXR period | 14 days |
| Bollinger Bands | 20 days, 2 deviations |
| Stop loss | 2% |
| Strategy file | ADX_ADXR_BBPct_Strategy.py |
The system completed 11 trades, winning four and losing seven. Its 36.36% win rate confirms that the strong return came from payoff asymmetry rather than frequent small wins.
The equity curve shows durable separation from a sharply declining UNH benchmark.
Maximum drawdown was 8.58%, giving this strategy the best return-to-drawdown relationship in the five-article replacement set.
The strategy beat UNH in 65.3% of 63-day windows, 81.3% of 126-day windows, and 90.0% of 252-day windows. Median 126-day excess return was 19.93%.
The distribution demonstrates how a low-win-rate system can still produce strong risk-adjusted performance when winners are allowed to dominate losers.
The result combines 53.88% absolute return, 82.08% excess return, a 1.35 Sharpe ratio, single-digit maximum drawdown, no open trade, and strong rolling dominance. It is exactly the type of backtest that deserves deeper out-of-sample work.
Explore the strategy package: Mega Backtrader Strategy Pack.
This article is for research and educational use only. Backtest results are not financial advice or a guarantee of future performance. Validate logic, sizing, costs, slippage, and out-of-sample results before trading.