The Bollinger Bands tracking strategy is a quantitative trading strategy based on Bollinger Bands. It calculates the upper and lower rails of the Bollinger Bands of a stock and sets buy and sell conditions to track the market. When the price touches the lower rail of the Bollinger Bands, the stock is considered undervalued, Thus providing more room for growth and generating a buy signal; when the price rises and touches the upper rail, the stock is considered overvalued, genTherefore considered to beerating a sell sign.
The core indicator of this strategy is Bollinger Bands. Bollinger Bands consist of three lines: middle rail, upper rail and lower rail. The middle rail is the n-day moving average closing price; the upper rail is the middle rail + k times the n-day standard deviation of the closing price; the lower rail is the middle rail - k times the n-day standard deviation of the closing price. The k value is usually set to 2. When the stock price is lower than the lower rail, it is at a relatively low price level, Therefore considered to be lowervalued, generating a buy signal; when the stock price is higher than the upper rail, it is at a relatively high price level and is considered overvalued, generating a sell signal.
Specifically, this strategy first calculates the 20-day moving average of closing prices as the middle rail, and then calculates twice the 20-day standard deviation of closing prices as the bandwidth. The upper rail is the middle rail + bandwidth and the lower rail is the middle rail - bandwidth. It then sets the buy condition to be closing price lower than the lower rail, and sell condition to be closing price higher than the upper rail. It generates a buy signal when closing price is below the lower rail, and a sell signal when closing price is above the upper rail.
This strategy has the following advantages:
There are also some risks with this strategy:
Corresponding solutions:
The main optimization directions for this strategy includes:
Overall, Bollinger Bands tracking strategy is a relatively simple and practical quantitative trading strategy. It can automatically track price trends and also provide buy and sell signals. The pros are easy implementation, smaller risks, filtering false breakouts. The cons are certain lagging, inability to face extreme market conditions like black swans. This strategy can be further enhanced through optimizing parameters and indicators, using more advanced techniques like machine learning. In summary, combining Bollinger Bands strategies with other technical strategies can form a robust and efficient quantitative trading system.
/*backtest start: 2024-01-01 00:00:00 end: 2024-01-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Bollinger Bands Strategy", shorttitle="BB Strategy", overlay=true) // Input parameters length = input(20, title="Bollinger Bands Length") mult = input(2, title="Multiplier") // Calculate Bollinger Bands basis = ta.sma(close, length) bb_upper = basis + mult * ta.stdev(close, length) bb_lower = basis - mult * ta.stdev(close, length) // Buy and sell conditions buy_condition = close < bb_lower sell_condition = close > bb_upper // Execute trades strategy.entry("Buy", strategy.long, when=buy_condition) strategy.entry("Sell", strategy.short, when=sell_condition) // Plotting Bollinger Bands on the chart plot(bb_upper, color=color.red, title="Upper Band") plot(bb_lower, color=color.green, title="Lower Band") plot(basis, color=color.blue, title="Basis") // Highlighting buy and sell signals on the chart bgcolor(buy_condition ? color.new(color.green, 90) : na) bgcolor(sell_condition ? color.new(color.red, 90) : na)