# Bollinger Bands (BB)

**Bollinger Bands** are a versatile volatility-based indicator that consists of a moving average (typically the 20-period SMA) and two bands plotted above and below it at a specified number of standard deviations. These bands expand and contract with market volatility and can help identify overbought/oversold conditions, breakouts, and potential reversals.

***

#### Why Use Bollinger Bands in your strategy?

Bollinger Bands are excellent for understanding **price volatility** and identifying **high-probability reversal zones** or **breakout opportunities**. Here’s what makes them useful:

* Detects **volatility compression and expansion**.
* Helps spot **price extremes** where reversals are more likely.
* Signals **breakouts** when price breaks outside the band after a squeeze.
* Effective for both **range-bound and trending market conditions**.
* Visual and beginner-friendly, yet powerful when used with other indicators.

***

#### BB Settings in the AlgoBuilder

When adding BB to your strategy inside the **AlgoBuilder**, you’ll be able to customize or use the following parameters:

| Setting                | Description                                                                    |
| ---------------------- | ------------------------------------------------------------------------------ |
| **Basis Length**       | Period used to calculate the central moving average (default: 20)              |
| **Source**             | Price source (close, open, high, low)                                          |
| **Std Dev Multiplier** | Number of standard deviations to plot the upper and lower bands (default: 2.0) |
| **Timeframe**          | Timeframe for the Bollinger Band calculation (e.g. 1m, 5m, 1h)                 |

***

#### 📈 Example Usage for Entry Conditions

**Mean Reversion LONG:**\
Enter long when price touches or briefly dips below the lower Bollinger Band.\
→ Suggests price may be oversold and due for a bounce.

**Breakout LONG:**\
Enter long when price closes above the upper band after a squeeze.\
→ Indicates strong momentum and possible trend continuation.

**Mean Reversion SHORT:**\
Enter short when price touches or exceeds the upper Bollinger Band.\
→ Suggests overbought conditions and potential pullback.

**Breakout SHORT:**\
Enter short when price closes below the lower band after a squeeze.\
→ Can signal start of new bearish trend.

***

#### 🎯 Take Profit / Exit (Long) Examples

**Exit at Middle Band (Basis):**\
Take profit when price reverts to the mid-band (moving average).\
→ A common mean reversion target.

**Exit if Price Closes Below Lower Band Again:**\
→ Might indicate further downside volatility and invalidation of the long setup.

***

#### 🎯 Take Profit / Exit (Short) Examples

**Exit at Middle Band (Basis):**\
Take profit when price retraces back to the mid-band.\
→ A natural spot for mean reversion.

**Exit if Price Closes Above Upper Band Again:**\
→ Suggests momentum reversal or breakout invalidation.

***

#### Tips for Using Bollinger Bands in the AlgoBuilder

* Combine BB with **RSI** to filter out false signals (e.g., only take BB longs if RSI is oversold).
* Use BB squeezes (tight band contraction) as a **pre-breakout signal**.
* Try longer periods (e.g., 50) to smooth out the bands for macro trend filtering.
* Great for building **hybrid strategies** — trend-following breakouts or counter-trend mean reversions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://algotrade-1.gitbook.io/docs/indicators-library-and-guide/bollinger-bands-bb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
