Bollinger Bands crossover signals: define the line and direction
A Bollinger Bands crossover occurs when price crosses a chosen upper, middle, or lower line. The phrase is incomplete until you name the line, crossing direction, price source, and whether the candle must close.
Direct answer
Define crossover signals as closed-bar state changes. For example, a lower-band re-entry requires the previous close below the lower band and the current close above it. Keep breakouts and re-entries as different alerts.
Starting values
Default length
20 bars
Default deviation
2.0
Signal timing
Bar close
Lines to name
Upper, basis, lower
How I test the setup
- 1
When I test an AAPL crossover, I write the previous-bar and current-bar conditions in plain language before coding them.
- 2
I give breakout and re-entry alerts different names. A cross above the upper band is not the same event as a cross back below it.
- 3
I count repeated crosses during sideways markets. A rule that looks clean on one screenshot can fire often when tested across several years.
Four outer-band crossover events
Each outer band supports a breakout event and a re-entry event. These four cases carry different hypotheses, so a script should expose them separately instead of drawing one generic buy or sell arrow.
- Upper breakout: close crosses from at or below the upper band to above it.
- Upper re-entry: close crosses from at or above the upper band to below it.
- Lower breakout: close crosses from at or above the lower band to below it.
- Lower re-entry: close crosses from at or below the lower band to above it.
The middle-band crossover answers another question
Crossing the basis tracks price relative to its moving average, not an outer-band extreme. It can act as a trend state or exit condition. If the same strategy uses outer-band entry and basis exit, label both in the test report.
Why crossover arrows repaint expectations
The Bollinger values and the current price both change while a candle is open. An intrabar cross may vanish by the close even when the script itself does not look ahead. Use bar-close alerts for reproducible historical and live behavior, then include fees and slippage in any strategy test.
Breakout and re-entry are opposite events
| Event | Previous close | Current close |
|---|---|---|
| Upper breakout | At or below upper band | Above upper band |
| Upper re-entry | At or above upper band | Below upper band |
| Lower breakout | At or above lower band | Below lower band |
| Lower re-entry | At or below lower band | Above lower band |
Bollinger crossover Pine Script prompt
The prompt names all four events and waits for the candle to close.
Create a Pine Script v6 Bollinger Bands crossover indicator with close, length 20, and multiplier 2. Detect upper breakout, upper re-entry, lower breakout, and lower re-entry using previous and current closed-bar values. Plot a different shape and create a separate alertcondition for each event. Add an optional basis crossover alert. Do not label any event as a guaranteed buy or sell signal.Generate crossover alerts
Related Bollinger Bands pages
Tools for the next test
Bollinger Bands Breakout Strategy Tutorial
Master the Bollinger Bands Squeeze and Breakout strategy on TradingView. Learn the Pine Script v5 code and professional analysis with Pineify.
Bollinger Bands Percent B
Calculate Bollinger %B, interpret the 0, 0.5, and 1 reference values, and generate exact threshold alerts.
Bollinger Bands and RSI
Combine Bollinger price location with a separate RSI momentum condition and inspect the resulting Pine Script rules.
How to Create Bollinger Bands in TradingView
Learn how to build and customize Bollinger Bands in TradingView using Pine Script. Master volatility trading with this step-by-step guide.
Bollinger Bands Calculator
Compute Bollinger Bands to analyze market volatility and potential price breakouts.
Sources and method notes
Pineify is an information tool, not investment advice. A crossover is a coded event, not a promise of direction or returns. Historical signals can fail in live markets.