Skip to content
All library documents

Bollinger Band Re-entry Strategy with Manual Controls and Position Tracking

Article Strategy library · Author: 发明者量化-小小梦

Summary

This example implements a simple long-only Bollinger Band strategy within a reusable trading framework. It buys when the latest close moves above the lower band after the prior close was below it, then sells when the close moves above the upper band after previously being below. A state variable tracks whether the system is flat or long, while interactive commands can trigger entries, exits, or update the order amount.

The program also displays account, market-depth, candle, and position information; marks trades on a chart; and estimates average entry price and floating and realized profit. The source includes a suggested two-percent stop-loss idea in a comment, but does not implement that stop. It provides no backtest results, and the framework code has operational caveats, including reliance on external helper functions and account-difference calculations that may be affected by fees, fills, or other transactions.

Key ideas

  • The example buys after price crosses back above the lower Bollinger Band and sells after crossing above the upper band.
  • A position state and interactive commands govern opening, closing, and changing order size.
  • The framework presents account, market, position, and profit estimates alongside chart trade markers.
  • The commented stop-loss suggestion is not implemented in the strategy logic.
  • No performance results are reported, and profit estimates depend on account balance and holdings changes.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.