Bollinger Bands and Fibonacci Intraday Trend Following Strategy

FMZQuant - Jan 20 - - Dev Community

Image description

Overview
This strategy is a day trading system that combines Bollinger Bands and Fibonacci retracement levels. It uses the Bollinger Band indicator to identify overbought and oversold conditions, while using Fibonacci retracement levels to confirm potential support and resistance levels, thereby capturing trading opportunities in market fluctuations. The strategy uses 20-period Bollinger Bands and three key Fibonacci levels of 0.236, 0.382, and 0.618 for signal generation.

Strategy Principle
The core logic of the strategy is based on the following key elements:

  1. Use the upper and lower Bollinger Bands (standard deviation is 2) to mark the overbought and oversold areas of prices
  2. Calculate the Fibonacci retracement level by using the highest and lowest prices of the last 20 periods
  3. A buy signal is generated when the price breaks above the lower Bollinger Band and above the Fibonacci 0.236 or 0.382 support levels
  4. A sell signal is generated when the price breaks above the upper Bollinger Band and below the Fibonacci 0.618 resistance level.
  5. Use fixed stop loss and take profit points to control risk and lock in profits

Strategy Advantages

  1. Combined with the dual confirmation mechanism of trend and support and resistance, the reliability of trading signals is improved
  2. Bollinger Bands can dynamically adapt to changes in market volatility, making the strategy highly adaptable
  3. Fibonacci levels provide a clear frame of reference for entries and exits
  4. Fixed stop loss and take profit settings help to strictly control risks
  5. Strategy parameters can be flexibly adjusted according to different market conditions

Strategy Risks

  1. Frequent false breakout signals may occur in a volatile market
  2. Fixed stop loss and take profit settings may not be suitable for all market conditions
  3. The effectiveness of Fibonacci levels is greatly affected by market structure
  4. In fast-trending markets, some market movements may be missed
  5. Parameters need to be continuously monitored and adjusted to adapt to market changes

Strategy Optimization Direction

  1. Introducing volume indicators to confirm the validity of the breakout
  2. Dynamically adjust stop loss and take profit levels according to market volatility
  3. Added trend filter to avoid trading in sideways markets
  4. Optimizing the calculation period of Fibonacci levels
  5. Consider adding time filters to avoid trading during low liquidity periods

Summary
This is a complete trading system that combines classic technical analysis tools, providing traders with a systematic trading framework through the synergy of Bollinger Bands and Fibonacci retracements. Although there are certain limitations, this strategy can play a good role in intraday trading through proper parameter optimization and risk management. The key is to make corresponding adjustments and optimizations based on specific trading products and market conditions.

Strategy source code

/*backtest
start: 2025-01-02 00:00:00
end: 2025-01-09 00:00:00
period: 10m
basePeriod: 10m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/

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

// Bollinger Bands settings
length = input.int(20, title="Bollinger Band Length")
src = close
mult = input.float(2.0, title="Bollinger Band Multiplier")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev

// Fibonacci retracement levels
fibRetrace1 = input.float(0.236, title="Fibonacci Level 0.236")
fibRetrace2 = input.float(0.382, title="Fibonacci Level 0.382")
fibRetrace3 = input.float(0.618, title="Fibonacci Level 0.618")

// Define the Fibonacci levels based on recent high and low
var float fibLow = na
var float fibHigh = na

if (bar_index == 0 or ta.highest(high, 20) != fibHigh or ta.lowest(low, 20) != fibLow)
    fibHigh := ta.highest(high, 20)
    fibLow := ta.lowest(low, 20)

fibLevel1 = fibLow + (fibHigh - fibLow) * fibRetrace1
fibLevel2 = fibLow + (fibHigh - fibLow) * fibRetrace2
fibLevel3 = fibLow + (fibHigh - fibLow) * fibRetrace3

// Plot Fibonacci levels on the chart
plot(fibLevel1, title="Fib 0.236", color=color.blue, linewidth=1)
plot(fibLevel2, title="Fib 0.382", color=color.green, linewidth=1)
plot(fibLevel3, title="Fib 0.618", color=color.red, linewidth=1)

// Buy and Sell conditions
buyCondition = close < lower and close > fibLevel1
sellCondition = close > upper and close < fibLevel3

// Plot Buy and Sell signals
plotshape(buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Execute strategy
if (buyCondition)
    strategy.entry("Buy", strategy.long)

if (sellCondition)
    strategy.entry("Sell", strategy.short)

// Exit strategy with stop loss and take profit
stopLoss = input.float(50, title="Stop Loss (pips)", minval=1)
takeProfit = input.float(100, title="Take Profit (pips)", minval=1)

strategy.exit("Exit Buy", "Buy", stop=close - stopLoss * syminfo.mintick, limit=close + takeProfit * syminfo.mintick)
strategy.exit("Exit Sell", "Sell", stop=close + stopLoss * syminfo.mintick, limit=close - takeProfit * syminfo.mintick)
Enter fullscreen mode Exit fullscreen mode

Strategy Parameters

Image description

The original address: Bollinger Bands and Fibonacci Intraday Trend Following Strategy

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .