SUPERALGOS DATA MINING

A Quantitative Study of the Bollinger Bands Squeeze Strategy

Can a simple strategy based on volatility indicators be profitable?

Thomas Huault
Superalgos | Algorithmic Trading

--

A bitcoin next to a bottle with a mysterious liquid.
Photo by Executium at Unsplash

In this article, we study a strategy taking advantage of Bollinger Bands squeezes to identify position entry points. In a first time, we will show the basic of the strategy with Bollinger Bands squeeze identification and entry/exit point highlighting. Using Knime will see what are the expected figures of the strategy to have a first sentiment on the relevant parameters to optimize and then we will perform backtests using Superalgos to study risk/money management to obtain the best outcome of this strategy.

Back to Basics

The Bollinger bands squeeze is a special pattern when the volatility of a market decreases after trending periods. It is generally observed the price is ranging during this period until a new trend starts and the volatility increases again.

To identify this pattern, we associate the Bollinger bands with the Keltner channels, looking for the moment where the Bollinger bands will be included between the limits of the Keltner channels.

The Bollinger Bands indicator

Bollinger bands are a volatility-based indicator constituted from a simple moving average, generally over 20 periods, surrounded by two bands situated at twice the standard deviation of the typical price HLC3 (Max + Min + Close)/3.

The bands are designed by initially calculating the SMA20 like:

From which we can deduce the standard deviation:

The upper and lower bands are then calculated like:

Bollinger Bands of the BTC/USDT pair on the 1-hs chart plotted using Superalgos

The Keltner Channels indicator

Keltner channels use a measure of the volatility to frame price movements around an exponential moving average. To evaluate the channels, we fist calculate an EMA20:

With s = 2 and P = 20.

The position of the bands is determined by the Average True Range, a moving average of the True Range:

The ATR is calculated as 10 periods moving average of TR:

The Keltner channels are calculated at twice the ATR above and below the EMA20:

Keltner Channels of the BTC/USDT pair using Superalgos on the 1-hs timescale chart

Interaction between Bollinger Bands and Keltner Channels: The Trading Strategy

Combined together, Keltner Channels and Bollinger Bands cumulate 90% of the price range. When both get closer, it is a sign of a decreasing volatility. If the Bollinger Bands become included in the Keltner channels the market is ranging since the standard deviation decreases.

We can use this pattern to seize a trading opportunity. If a low volatility period, i.e. a non-trending price, is underlined by Bollinger bands included in Keltner channels, once one of the Keltner channels crosses the Bollinger band, a new trend can be spotted:

  • If the lower Keltner channel crosses over the lower Bollinger band, an upward trend start
  • If the upper Keltner channel crosses under the upper Bollinger band, a downward trend starts

We propose to study the following common strategy based on these special patterns:

  • Open a position with a market buy order if the lower Keltner channel crosses over the lower Bollinger band and the upper Keltner channel is above the upper Bollinger band
  • Exit the position with a market sell order once the lower Keltner channel leaves the Bollinger bands by crossing under the lower band while the upper Keltner channel is still above the upper band
Superposition of the Keltner Channels and the Bollinger Bands on the 1-hs timescale chart of BTC/USDT pair in Superalgos

Statistics on basic simulation

We use Knime Analytics to perform basic simulation of the Keltner/Bollinger strategy. We choose the 1-hour time frame for indicators calculation and a trading rate at 1-hour. For basic simulation no Take-profit or Stop-loss is set and we simulate position opening and closing at the end of the period following the detection of the take position event.

The simulation period is from 1st of January 2021 up to December. The performance of the strategy is evaluated with the total return on the testing period, considering the profit/loss is compounded at each position.

The outcome of the simulation is unfavorable. We observe a total of 76 trades with a hit ratio of 54% but with a total return showing a 15.8% loss. The best trade generated a 19% profit whereas the worst trade ended with an 28.7% loss. The return at individual trades shows a distribution with a clear orientation to non-profitable outcome.

The total return has reached a maximum value of 1.669 so a profitable outcome should be reach with an adapted risk management. We propose to test this asumption using the backtesting capacities of Superalgos.

Backtesting with Superalgos

Using Superalgos we produced several backtesting session to explore the trading system parameters of the keltner/Bollinger strategy.

In a first time we use the basic strategy as designed and studied with Knime.

Screenshot of the Superalgos chart after the backtesting session

The outcome of the backtesting is actually devastating. With 55 trades and a hit ratio of 55%, we observe a total loss of the initial capital. We have superposed a Supertrend 14/3 indicator to try to identify potential improvements to make this strategy profitable.

First, as discussed at the simulation, some trades show very important loss and the major improvement is definitely to implement Stop-loss and Take-profit management.

In a second time, looking at the position of the trades regarding the trend highlights by the Supertrend indicator, even if the strategy triggers show trading opportunities, those taken while the trend is downward have a major proportion of the loss.

Finally, a non negligible part of the loosing trades are positioned in conditions where the indicators crossing is choppy and results in a premature position exit.

We then suggest to implement three improvements :

  • Stop-loss / Take-profit management based on the value of the ATR at the moment where the market buy order is fired
  • Avoid to open a position when the Supertrend indicator shows a downward trend
  • Dampen the effects of early position exits by changing the trading pace versus the indicators time frame

For our first try, we set a condition to fire the market buy order only if the trend given by the Supertrend 14/3 at 4-hours time frame is upward.

Screenshot of the Superalgos chart after the backtesting session with the Supertrend filter

This first result is empowering. From a situation where we observed a total loss, the strategy becomes profitable… about 2.7 %.

For our second try we have kept the Supertrend filter and set the indicator time scale at 4-hours with a trading pace of 1 hour.

Screenshot of the Superalgos chart after the backtesting session with the Supertrend filter and the indicators at the 04-hours time frame

The change in the indicators time frame leads to and interesting outcome. The strategy is now profitable with only 13 trades and a hit ratio about 57%. The profit reaches 31.9%.

Now our last improvement idea is about the Stop-loss and Take-profit management. The expected results are a better profit per trade and eventually, since the bot will cut losing trades quickly, a higher number of trades.

Screenshot of the Superalgos chart after the backtesting session with the Supertrend filter and the indicators at the 04-hours time frame with Stop-Loss and Take-profit optimization

For this part of the study we have seen immediate improvement even at the very first steps of the SL/TP optimization. The above chart shows the results with an optimized risk ratio for Stop-Loss at 4 x ATR and Take-Profit at 6 x ATR, considering the ATR at the moment the market buy order is fired (non trailing ATR based risk management). The strategy exhibits now an 87.65% profit with 26 trades a 54% hit ratio. Our intuition on the effect of SL/TP is confirmed and we achieved an interesting potential profit with this strategy. As a comparison, the BTC/USDT pair achieved 61% profit with a simple buy and hold strategy.

Conclusion

We have studied a trading strategy based on volatility indicators, taking advantage of Bollinger bands squeeze highlighting with the Keltner channels. From a totally loosing situation with 15.8% loss at the very basic simulation and a 100% loss at the first backtesting attempts, we have shown we could achieve a profitable trading strategy, beating the buy and hold strategy on BTC/USDT market (87.65% versus 61%), by actually implementing the very basis of trading : indicator confirmation, trading at different time frames and risk management.

Demo Strategy Available Within Superalgos

This strategy is fully implemented in the Keltner Bollinger strategy workspace within Superalgos as a ready-to-use system with a dedicated non-plugin data mine, and a non-plugin trading system.

The Trading system and the Data mine used at the workspace are available as independent plugins.

The different indicators used in the data mine can be found in other Data mine : Quasar, Pluvtech, Bollinger, Polus.

Disclaimer: The content of this article is for educational purpose only and does not constitute financial advice. Trading is not suitable for everybody; seek professional advice. Use this article at your own risk.

If you enjoyed this article and want to participate in the most promising open-source social trading platform… come and join us !

--

--

Thomas Huault
Superalgos | Algorithmic Trading

Seasoned project Manager and data scientist with a strong background in physics, I lead the Data Mining initiative of the social trading Platform Superalgos.