Strategy vault / Mean reversion
Multi Period Bollinger Bands Touch Trend Reversal Quantitative Trading Strategy
This strategy is a trend reversal trading system based on the Bollinger Bands indicator, which captures market reversal opportunities by monitoring the relationship between price and Bollinger Bands. The strategy…

Overview
This strategy is a trend reversal trading system based on the Bollinger Bands indicator, which captures market reversal opportunities by monitoring the relationship between price and Bollinger Bands. The strategy operates on a 5-minute timeframe, using a 20-period moving average as the middle band and 3.4 standard deviations for the upper and lower bands. Trading signals are generated when prices touch the upper or lower bands.
Strategy Principle
The core logic is built on mean reversion theory. When price touches the lower band, the system considers the market oversold and tends to go long; when price touches the upper band, the system considers the market overbought and tends to go short. Specifically:
- Long condition: When the 5-minute candlestick's low first touches or breaks the lower band (current low <= lower band AND previous low > lower band)
- Short condition: When the 5-minute candlestick's high first touches or breaks the upper band (current high >= upper band AND previous high < upper band)
- Exit condition: Close positions when price reverts to the middle band
Strategy Advantages
- Rational indicator selection: Bollinger Bands integrate trend and volatility information for effective market state identification
- Precise entry timing: Captures reversal signals through first touch of bands, avoiding chasing trends
- Robust risk control: Uses moving average as profit-taking benchmark, protecting profits without premature exits
- Scientific parameter configuration: 3.4 standard deviation setting effectively filters false signals
- Clear system structure: Simple and intuitive trading logic, easy to maintain and optimize
Strategy Risks
- Trend breakthrough risk: In strong trend markets, continuous band breakouts may lead to frequent stops
- Range-bound market risk: May generate excessive false signals during consolidation periods
- Parameter sensitivity: Minor changes in Bollinger Bands parameters can significantly impact strategy performance
- Slippage impact: High volatility environments may face severe slippage affecting strategy performance
- Timeframe dependency: Strategy performance may vary significantly across different timeframes
Strategy Optimization Directions
- Multiple timeframes: Introduce longer period Bollinger Bands for confirmation to improve signal reliability
- Trend filtering: Add trend identification indicators to only trade in clear trend directions
- Dynamic parameters: Adapt Bollinger Bands parameters based on market volatility
- Stop-loss optimization: Implement trailing stops or ATR-based stops to improve risk control
- Position management: Dynamically adjust position sizes based on signal strength and market volatility
Summary
This strategy captures market reversal opportunities through Bollinger Bands touches, featuring clear logic and reasonable risk control. Through appropriate parameter settings and comprehensive trading rules, the strategy shows good stability in range-bound markets. However, when applying to live trading, attention must be paid to trend breakthrough risks. It is recommended to combine other technical indicators for trade confirmation and dynamically adjust strategy parameters based on market conditions. Optimization focuses mainly on multi-period coordination, trend filtering, and dynamic parameter adjustment.
Source Pine Script
/*backtest
start: 2024-11-11 00:00:00
end: 2024-12-11 00:00:00
period: 5h
basePeriod: 5h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("5-Min Bollinger Bands Touch Strategy", overlay=true, margin_long=100, margin_short=100)
// Input parameters
length = input(20, title="Bollinger Bands Length")
mult = input(3.4, title="Bollinger Bands Deviation")
// Bollinger Bands calculation
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// Plot Bollinger Bands
plot(basis, color=color.blue, title="Basis")
p1 = plot(upper, color=color.red, title="Upper Band")
p2 = plot(lower, color=color.green, title="Lower Band")
fill(p1, p2, color=color.new(color.gray, 90))
// Bullish buying condition: 5-min low touches lower Bollinger Band
bullish_entry = low <= lower and low[1] > lower[1]
// Bearish selling condition: 5-min high touches upper Bollinger Band
bearish_entry = high >= upper and high[1] < upper[1]
// Entry and exit conditions
longCondition = bullish_entry
shortCondition = bearish_entry
// Strategy entries
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Optional: Add exit conditions (you may want to customize these)
// Example: Exit long position after a certain profit or loss
strategy.close("Long", when = high >= basis)
strategy.close("Short", when = low <= basis)
// Alerts
alertcondition(bullish_entry, title='Bullish BB Touch', message='5-min low touched Lower Bollinger Band')
alertcondition(bearish_entry, title='Bearish BB Touch', message='5-min high touched Upper Bollinger Band')
// Plot entry points
plotshape(bullish_entry, title="Bullish Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green)
plotshape(bearish_entry, title="Bearish Entry", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red)Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-12. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Multi-Period-Bollinger-Bands-Touch-Trend-Reversal-Quantitative-Trading-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- Bollinger Bands ATR Risk Reward Trading StrategyPine Script · Mean reversion · 1d
- Dual Moving Average RSI Synergy Options Quantitative Trading StrategyPine Script · Mean reversion · 1h
- Enhanced Bollinger Mean Reversion Quantitative StrategyPine Script · Mean reversion · 1d
- Multi Indicator Reversal Point Capture Trading StrategyPine Script · Mean reversion · 1d
- Multi Timeframe Adaptive Mean Reversion with Volume Analysis StrategyPine Script · Mean reversion · 1h
- Reversal Trading Strategy with Bollinger Bands RSI ADX and ATRPine Script · Mean reversion · 1h