0bps

Strategy vault / Trend following

Bollinger Bands Accurate Entry And Risk Control Strategy Bollinger Bands

This strategy uses Bollinger Bands as the main indicator. By analyzing the relationship between price and the upper and lower bands, it enters trades under specific conditions. The main idea of the strategy is: when…

Author
ChaoZhang
Complexity
Starter · 45 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy uses Bollinger Bands as the main indicator. By analyzing the relationship between price and the upper and lower bands, it enters trades under specific conditions. The main idea of the strategy is: when the closing price breaks above the upper band, it goes long; when it breaks below the lower band, it goes short. At the same time, it uses opposite signals to close positions, thereby capturing price fluctuations.

Strategy Principle

  1. Calculate the middle, upper, and lower bands of the Bollinger Bands. The middle band is the simple moving average of the closing price, and the upper and lower bands are the middle band plus or minus a certain multiple of standard deviations.
  2. When the closing price breaks above the upper band, it triggers the long condition and opens a long position.
  3. When the closing price breaks below the lower band, it triggers the short condition and opens a short position.
  4. When holding a long position, if the short condition appears, the long position is closed.
  5. When holding a short position, if the long condition appears, the short position is closed.

Strategy Advantages

  1. Bollinger Bands can effectively reflect price fluctuations, and using them as trading signals has a certain degree of reliability.
  2. The strategy logic is clear and easy to understand and implement.
  3. In trending markets, this strategy can capture price fluctuations well and obtain good returns.
  4. The strategy does not use too many indicators, reducing noise interference and improving the effectiveness of signals.

Strategy Risks

  1. In range-bound markets, this strategy may experience frequent trading, leading to high transaction costs.
  2. The selection of Bollinger Band parameters has a significant impact on strategy performance, and inappropriate parameters may cause the strategy to fail.
  3. The strategy does not set a stop loss, which may face greater risks when the market reverses sharply.
  4. The strategy does not consider the characteristics of different trading instruments, and parameters may need to be adjusted for different instruments.

Strategy Optimization Directions

  1. Introduce other indicators, such as trend or oscillator indicators, to confirm Bollinger Band signals and improve trading accuracy.
  2. Optimize parameters, such as the period and standard deviation multiple of Bollinger Bands, to adapt to different market conditions.
  3. Set reasonable stop losses and take profits to control single transaction risk.
  4. Adjust the strategy according to the characteristics of trading instruments, such as volatility and liquidity.
  5. Consider introducing position management to dynamically adjust positions according to market conditions and improve the risk-return ratio.

Summary

This strategy uses Bollinger Bands as the core and conducts trades under specific conditions by analyzing the relationship between price and Bollinger Bands. The strategy logic is clear and easy to understand and implement. It can obtain good returns in trending markets. However, it also has some risks, such as frequent trading and improper parameter selection. By introducing other indicators, optimizing parameters, setting stop losses and take profits, and other methods, the performance of the strategy can be further improved to better adapt to different market environments.

Source Pine Script

/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Bollinger Bands Strategy", overlay=true)

src = input(close)
length = input.int(34, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)

basis = ta.sma(src, length)
dev = ta.stdev(src, length)
dev2 = mult * dev

upper1 = basis + dev
lower1 = basis - dev
upper2 = basis + dev2
lower2 = basis - dev2

// Long Condition: Close above Upper Bollinger Band
longCondition = close > upper1

// Short Condition: Close below Lower Bollinger Band
shortCondition = close < lower1

// Strategy Entry and Exit
strategy.entry("Long", strategy.long, when = longCondition)
strategy.entry("Short", strategy.short, when = shortCondition)

// Close Long Position when Short Condition is Met
strategy.close("Long", when = shortCondition)

// Close Short Position when Long Condition is Met
strategy.close("Short", when = longCondition)

// Plotting Bollinger Bands
plot(basis, color=color.blue)
plot(upper1, color=color.new(color.blue, 80))
plot(lower1, color=color.new(color.orange, 80))

Published by ChaoZhang on the FMZ strategy square · last modified 2024-06-03. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Bollinger-Bands-Accurate-Entry-And-Risk-Control-Strategy-Bollinger-Bands.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open