Bollinger Band Breakout Entries with Midline Exits
Summary
This strategy uses Bollinger Bands calculated from hourly closing prices to generate long and short trades. It enters long when the latest tick rises above the upper band and enters short when it falls below the lower band. A long is closed below the middle band; a short is closed above it. The bands use a 40-period window and a 2.5 standard-deviation setting, and the code discards a still-open final hourly candle before updating them.
Position size is based on a configured trade amount divided by the latest close, rounded to a minimum quantity. The implementation sends limit orders priced slightly beyond the current market and persists its signal levels and intended position. It also compares the strategy position with exchange-reported holdings and may cancel open orders and submit a corrective order. The document supplies implementation details but no backtest or performance evidence. Its position state is updated when orders are submitted, so pending or partially filled orders and execution differences can make it diverge from actual holdings.
Key ideas
- The strategy enters long above the upper Bollinger Band and short below the lower band.
- Long positions exit below the middle band, while short positions exit above it.
- Bands are calculated from closed hourly candles using a 40-period window and 2.5 standard deviations.
- Trade quantity is derived from a configured trade amount and rounded to a minimum size.
- The implementation persists intended position state and includes a routine to reconcile it with exchange holdings.
Tags
From a private course collection; the original is not published.