All indicators

Trend Following with Bollinger Bands

Dec 11, 2021

Static chart image
SignalsChannelsMoney ManagementMoving AveragesTrailing-StopVolatility

The Trend Following with Bollinger Bands indicator is a comprehensive strategy tool designed to identify and execute trend-following trades by combining Bollinger Bands volatility envelopes with Exponential Moving Average (EMA) filters. This script aims to capture momentum in trending markets while utilizing volatility-based exits to manage risk effectively.

Usage

The tool identifies potential trade entries based on the confluence of price action relative to volatility bands and moving average alignment.

Long Positions:

  • Price must close above the upper Bollinger Band.
  • The Fast EMA (default 40) must be positioned above the Slow EMA (default 120), indicating a bullish trend regime.

Short Positions:

  • Price must close below the lower Bollinger Band.
  • The Fast EMA must be positioned below the Slow EMA, indicating a bearish trend regime.

Risk Management: The script includes an integrated ATR-based trailing stop. The trailing stop adjusts dynamically with market volatility, providing a systematic exit point that locks in profits during extended trends or cuts losses when the trend reverses by a specified multiple of the Average True Range.

Details

This strategy adapts the logic of classic Donchian Channel breakout systems but substitutes Bollinger Bands to account for standard deviation and price volatility. By requiring an EMA filter, the script attempts to filter out "head-fakes" or low-conviction breakouts that occur during sideways or choppy market conditions.

The strategy also features a position-sizing algorithm. It calculates the trade quantity based on a user-defined risk percentage of the initial capital, normalized by the current ATR. This ensures that trade size is reduced during high-volatility periods and increased during low-volatility periods to maintain a consistent risk profile.

Settings

Bollinger Bands Inputs

  • Length: The lookback period for the basis (SMA) and standard deviation calculation.
  • Source: The price source used for the bands (default is Close).
  • StdDev: The multiplier for the standard deviation to determine the width of the bands.
  • Offset: Shifts the Bollinger Bands forward or backward in time.

Moving Average Inputs

  • Length Fast MA: The period for the short-term Exponential Moving Average.
  • Length Slow MA: The period for the long-term Exponential Moving Average.

ATR Position Size Inputs

  • Leverage Used: Multiplier for the position calculation.
  • Point Value/ATR Multipliers: Defines the distance used for the initial risk calculation.
  • ATR Period: The lookback period for the ATR used in position sizing.
  • Risk Per Trade: The fraction of equity to risk on a single trade.

ATR Trailing Stop Inputs

  • ATR Period: The lookback period for the trailing stop calculation.
  • ATR Multiplier: The distance from the price (in ATR units) where the stop loss is placed.

FAQ

How do I use the Trend Following with Bollinger Bands?

You can apply this tool to any timeframe to identify trend breakouts confirmed by moving average alignment. Look for price closes outside the bands while the EMAs are in the correct orientation.

What is the purpose of the EMA filter?

The EMA filter ensures that you are only taking breakouts in the direction of the broader market trend, helping to avoid counter-trend signals that may result in false breakouts.

Where can I access this script?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.