Bollinger Bands Based Quantitative Trading Strategy

Author: ChaoZhang, Date: 2023-12-28 15:54:07
Tags:

img

Overview

This strategy builds a trading strategy based on the Bollinger Bands indicator to achieve automated trading on bitcoin futures 1-minute time frame. It goes long when the price breaks through the lower bound of the Bollinger Bands and goes short when the price breaks through the upper bound of the Bollinger Bands to make profits.

Strategy Principle

The strategy uses the Bollinger Bands indicator with 55 periods and a bandwidth coefficient set to 4. The middle line of the Bollinger Bands is the 55-day simple moving average, and the upper and lower lines are the middle line +4 times the standard deviation and the middle line -4 times the standard deviation respectively. When the price falls below the lower line, go long; when the price rises above the upper line, go short.

After the long signal is triggered, the strategy will set a stop loss order at the price of the lower line. After the short signal is triggered, the strategy will set a stop loss order at the price of the upper line. No take profit orders are set.

Advantage Analysis

The strategy utilizes the Bollinger Bands indicator’s ability to determine overbought and oversold conditions to reasonably determine entry timing. The bandwidth coefficient is set to 4 to avoid excessively frequent trading. Backtest results show that on the bitcoin 1-minute time frame, the strategy achieves a profitable probability of over 80%, with significant effect.

Compared with other indicators, the Bollinger Bands indicator adapts very well to market fluctuations and can automatically adjust the bandwidth to capture volatility in different periods. This makes the strategy’s parameters very robust.

In addition, the strategy relies solely on the Bollinger Bands indicator, which is very simple and meets the requirements for quantitative trading.

Risk Analysis

The main risk of this strategy lies in the fact that the Bollinger Bands indicator’s effect of judging overbought and oversold market conditions can be affected by huge market moves. In a bull market, stock prices may run high for an extended period, making it difficult for the upper rail to form effective resistance. Similarly, in a bear market, stock prices may stay low for an extended period, making it hard for the lower rail to provide effective support. All this can lead to invalid trading signals being generated by the strategy.

In addition, setting stop loss directly at the upper and lower rails of the Bollinger Bands may be too close, failing to give the strategy enough room and thus getting knocked out by price fluctuations.

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Combine with other indicators. Indicators like KDJ and MACD can help judge extreme overbought/oversold conditions to modify trading signals.

  2. Set trailing stop loss to lock in profits. Compared with static stop loss, trailing stop loss can adjust stop loss position appropriately based on price fluctuation.

  3. Optimize parameters. Different periods and bandwidth parameters of Bollinger Bands can be tested to find the optimal parameter combination. Optimization algorithms can also be used to find the optimal parameters.

  4. Adjust parameters according to market conditions. The market has three states: bull, bear and range-bound. So parameters can be set separately based on market conditions.

  5. Add advanced leverage management strategies. Manage the strategy’s risk profile by dynamically adjusting leverage.

Conclusion

The biggest strength of this strategy is its simple and clear trading logic of getting overbought/oversold signals from the Bollinger Bands indicator. Overall, it is a very practical short-term quantitative strategy. We can further improve it by optimizing it in many ways to achieve long-term steady profits.


/*backtest
start: 2023-11-27 00:00:00
end: 2023-12-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Kozlod - BB Strategy - 1 minute", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

// 
// author: Kozlod
// date: 2019-05-29
// BB - XBTUDS - Bitmex - 1m
// https://www.tradingview.com/u/Kozlod/
// https://t.me/quantnomad
//

source = close
length = input(55, minval=1)
mult = input(4, minval=0.001, maxval=50)

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

plot(upper)
plot(lower)

buyEntry  = crossover(source, lower)
sellEntry = crossunder(source, upper)

if (crossover(source, lower))
    strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands",  comment="BBandLE")
else
    strategy.cancel(id="BBandLE")

if (crossunder(source, upper))
    strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", comment="BBandSE")
else
    strategy.cancel(id="BBandSE")

More