
This strategy is a dynamic trading system based on the Bollinger Bands indicator, primarily generating trading signals through price crossovers with Bollinger Bands and using price touches of band boundaries as dynamic exit conditions. The strategy effectively utilizes Bollinger Bands as price volatility ranges, seeking trading opportunities when prices deviate from the mean and employing dynamic exit mechanisms to protect profits and control risks.
The core logic includes the following key elements: 1. Entry Signal Generation: Long positions are opened when the closing price crosses above the lower band; short positions are opened when the closing price crosses below the upper band. 2. Exit Signal Generation: For long positions, automatic closure occurs when the candle’s high touches or exceeds the upper band; for short positions, closure happens when the candle’s low touches or falls below the lower band. 3. Parameter Settings: Bollinger Bands period is set to 10, with a standard deviation multiplier of 2.0, these parameters can be optimized based on the actual trading instrument and timeframe.
This strategy constructs a complete trading system using Bollinger Bands, featuring clear trading logic and risk management mechanisms. While some potential risks exist, appropriate parameter optimization and strategy improvements can further enhance its performance across different market environments. The strategy’s core advantage lies in its dynamic adaptation to market volatility, making it particularly suitable for highly volatile market conditions.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//
// #######################################
// # #
// # Taexion #
// # #
// #######################################
//
//@version=6
strategy("Bollinger Strategy: Close at Band Touch v6", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=1000)
// Bollinger Bands parameters
length = input.int(10, title="Bollinger Period")
mult = input.float(2.0, title="Multiplier", step=0.1)
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// Plotting the bands
plot(basis, color=color.blue, title="Base")
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.blue, 90), title="Band Fill")
// Entry signals
longEntry = ta.crossover(close, lower)
shortEntry = ta.crossunder(close, upper)
if longEntry
strategy.entry("Long", strategy.long)
if shortEntry
strategy.entry("Short", strategy.short)
// Exit conditions based on touching the bands
// If in a long position and the candle's high touches or exceeds the upper band, close long.
if strategy.position_size > 0 and high >= upper
strategy.close("Long")
// If in a short position and the candle's low touches or falls below the lower band, close short.
if strategy.position_size < 0 and low <= lower
strategy.close("Short")