Want the full code behind this test? The Mega Backtrader Strategy Pack includes 500+ Backtrader-ready Python strategies, batch runners, dashboards, CSV metrics, chart exports, and documentation. You can get the full package here: Mega Backtrader Strategy Pack.
A volatility squeeze can mark a market preparing for expansion. The problem is that many squeezes fail. This strategy filters squeeze breakouts with volume, MACD, and trend direction, producing a 41.43% BTC-USD return with 10 closed trades.
The test used BTC-USD daily candles from July 27, 2024 to July 27, 2026. The benchmark was BTC buy-and-hold over the same period.
| Result | Value |
|---|---|
| Strategy return | 41.43% |
| BTC buy-and-hold return | -3.70% |
| Excess return | 45.12% |
| Final portfolio value | $14,142.82 |
| Sharpe ratio | 0.86 |
| Max drawdown | 22.44% |
| Closed trades | 10 |
| Open trades | 0 |
| Win rate | 50.00% |
FilteredSqueezeStrategy is a Bollinger/Keltner
squeeze breakout with volume and trend filters strategy.
The strategy is useful because it does not buy every contraction. It waits for compression first, then asks whether the breakout has momentum, volume, and trend support.
The strategy logic is:
The squeeze combines Bollinger Bands and a custom Keltner Channel:
self.bband = bt.indicators.BollingerBands(self.data, period=self.p.bb_period, devfactor=self.p.bb_devfactor)
self.keltner = CustomKeltnerChannel(self.data, period=self.p.kc_period, devfactor=self.p.kc_devfactor)A squeeze exists when Bollinger Bands contract inside Keltner bounds:
is_squeeze = (
self.bband.top < self.keltner.top and
self.bband.bot > self.keltner.bot
)The entry requires squeeze, breakout, MACD, volume, and trend alignment:
if not self.position and is_squeeze and has_volume_spike:
price_breaks_up = self.data.close[0] > self.bband.top[0]
macd_is_bullish = self.macd.macd[0] > self.macd.signal[0]
if price_breaks_up and macd_is_bullish and is_long_term_uptrend:
self.order = self.buy()This is the benefit of packaging the idea as a Backtrader strategy: the indicator setup, signal rules, position management, and output metrics all run through the same repeatable research workflow.
| Setting | Value |
|---|---|
| Asset | BTC-USD |
| Benchmark | BTC-USD |
| Period | 2y |
| Data window | July 27, 2024 to July 27, 2026 |
| Interval | 1d |
| Starting cash | $10,000.00 |
| Final value | $14,142.82 |
| Strategy file | FilteredSqueezeStrategy.py |
| Strategy class | FilteredSqueezeStrategy |
| Metric | Value |
|---|---|
| Starting portfolio value | $10,000.00 |
| Final portfolio value | $14,142.82 |
| Strategy return | 41.43% |
| BTC buy-and-hold return | -3.70% |
| Excess return vs BTC buy-hold | 45.12% |
| Sharpe ratio | 0.86 |
| Max drawdown | 22.44% |
| Total trades | 10 |
| Closed trades | 10 |
| Open trades | 0 |
| Winning trades | 5 |
| Losing trades | 5 |
| Win rate | 50.00% |
| Runtime | 2.19 seconds |
The run ended with no open trade, so the trade count and final equity are fully closed-position results.
The equity curve shows whether the strategy built its return steadily or relied on one isolated jump. Here the comparison is especially useful because BTC buy-and-hold finished negative while the strategy finished strongly positive.
The drawdown chart shows how much pain the strategy had to absorb during the test. Return alone is not enough; a publishable strategy review needs the drawdown path next to the benchmark.
The rolling return chart shows when the strategy gained or lost its edge. This helps separate one lucky ending from a result that developed across the test window.
The daily return distribution excludes zero-return strategy days. In this run, 455 flat strategy-equity days were removed, leaving 275 non-zero strategy return days plotted.
The main lesson is not that one backtest is automatically tradable. The lesson is that the research workflow matters. A useful strategy package should let you move from idea, to code, to batch test, to metrics, to charts, to publishable research without rebuilding the same infrastructure over and over.
That is exactly what the Mega Backtrader Strategy Pack is designed to do. It gives you hundreds of ready-to-run strategy modules plus the tooling to test them across assets and time windows.
Get the full package here: Mega Backtrader Strategy Pack.
This article is for research and educational use only. Backtest results are not financial advice, investment advice, or a guarantee of future performance. Always validate strategy logic, data quality, execution assumptions, costs, slippage, and risk before using any trading system.