Skip to content
All library documents

Plotting Bollinger Band Long and Short Signals

Article Quant Q&A · Author: quantManKid

Summary

The document asks how to mark long and short entry points on a stock chart that already displays price and Bollinger Bands. The proposed signal rules are to go long when price moves upward through the lower band and short when it falls below the upper band. The practical goal is to show those events as vertical lines on a Matplotlib plot using data held in pandas frames.

The text provides no implementation, backtest, or performance evidence, and it does not explain how to define crossings precisely or handle repeated signals. It also leaves the trading logic underspecified: the stated short rule refers to moving below the upper band, which can occur in many market conditions. Readers should treat the rules as a plotting question rather than a validated strategy; the document does not discuss exits, transaction costs, risk controls, or whether the signals have predictive value.

Key ideas

  • The question concerns marking entry events on a price chart with Bollinger Bands.
  • A long signal is described as price crossing upward through the lower band.
  • A short signal is described as price falling below the upper band.
  • The document does not provide code or evidence that these rules are profitable.

Tags

Full text
# How to add buy/sell market on a long/short Bollinger Bands graph in python?


# How to add buy/sell market on a long/short Bollinger Bands graph in python?












I am using `python`, `pandas`, `matplotlib` to do the following:

I have plotted some stock data with it's Bollinger bands. The data plotted is `lower_BB`, `upper_bb`, and `df_data`.

- `lower_bb` is a data frame containing the lower Bollinger band data

- `upper_bb` is a data frame containing the upper Bollinger band data.

- `df_data` is a data frame containing data for one stock.

The plot is coming out correctly, but now I want to add vertical lines on my graph where I go long or short a stock. I am slightly confused as how I should do this?

I want to long a stock if the df_data goes upward through the lower bollinger band and I want to short a stock if the df_data drops below the upper bollinger band. Any suggestions on how to do this?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

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