Skip to content
All library documents

Bollinger Band Mean Reversion on a Spread

Code Quant course library

Summary

This spread strategy uses Bollinger Bands to enter and exit positions. After building spread bars and waiting for its array manager to initialize, it calculates the moving average and upper and lower bands over a configurable window. When flat, it opens a short position if the close reaches the upper band, or a long position if the close reaches the lower band. It closes or reverses exposure when price returns to the middle band.

Orders use configurable position limits and execution parameters, and active algorithms are stopped on each new spread bar before signals are reconsidered. The document provides implementation details only; it reports no backtest or live results. It does not explain spread construction, parameter selection, transaction cost impact, or risk controls beyond the maximum position, so those choices require separate evaluation.

Key ideas

  • The strategy generates spread bars from incoming spread ticks and waits for indicator initialization.
  • It uses Bollinger Bands to enter short above the upper band and long below the lower band when flat.
  • Positions are exited when the spread returns to the middle band.
  • Maximum position and execution settings are configurable parameters.
  • The code gives no evidence of profitability or guidance on selecting parameters.

Tags

From a private course collection; the original is not published.