Skip to content
All library documents

Bollinger Band and RSI Oversold Entry Strategy

Code Freqtrade

Summary

This Freqtrade strategy combines a 14-period Relative Strength Index with 20-period Bollinger Bands calculated from typical price using two standard deviations. It enters a long position when RSI is below 30 and the close is below the lower band, treating agreement between an oversold reading and a downside band breach as an entry signal. It exits when RSI rises above 70.

The example also sets a one-hour timeframe, a minimal return-on-investment target, and a stop loss. These are configuration choices, not evidence that the approach is profitable. The document provides implementation logic but no backtest, market selection, trading costs, or performance analysis. A band breach can accompany a sustained decline, and an RSI threshold alone does not establish a reversal, so the rules require independent testing and risk controls before practical use.

Key ideas

  • The strategy enters long when RSI is below 30 and price closes below the lower Bollinger Band.
  • The Bollinger Bands use a 20-period window and two standard deviations.
  • The strategy exits when RSI rises above 70.
  • The example specifies a one-hour timeframe, a return target, and a stop loss but gives no performance evidence.

Tags

Full text
# BbandRsi.py


```py
# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


# --------------------------------


class BbandRsi(IStrategy):
    """

    author@: Gert Wohlgemuth

    converted from:

    https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/BbandRsi.cs

    """

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # adjust based on market conditions. We would recommend to keep it low for quick turn arounds
    # This attribute will be overridden if the config file contains "minimal_roi"
    minimal_roi = {
        "0": 0.1
    }

    # Optimal stoploss designed for the strategy
    stoploss = -0.25

    # Optimal timeframe for the strategy
    timeframe = '1h'

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)

        # Bollinger bands
        bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
        dataframe['bb_lowerband'] = bollinger['lower']
        dataframe['bb_middleband'] = bollinger['mid']
        dataframe['bb_upperband'] = bollinger['upper']

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                    (dataframe['rsi'] < 30) &
                    (dataframe['close'] < dataframe['bb_lowerband'])

            ),
            'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                    (dataframe['rsi'] > 70)

            ),
            'exit_long'] = 1
        return dataframe

```

Shown in full with attribution under the source's licence. Licence: GPL-3.0

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