Great discount if you pay using cryptocurrencies! Bitcoin, Litecoin & Dash accepted.


There are multiple ideas that you can use to trade with BollingerBands, first we need to know if we’re going to use Talib bollinger bands or qtpylib, for this example, I’ll choose qtpylib bollinger bands and the RSI provided by Talib library.

To check the indicators available in qtpylib you can check here:

The bollinger band code is the following:

def bollinger_bands(series, window=20, stds=2):
    ma = rolling_mean(series, window=window, min_periods=1)
    std = rolling_std(series, window=window, min_periods=1)
    upper = ma + std * stds
    lower = ma - std * stds

    return pd.DataFrame(index=series.index, data={
        'upper': upper,
        'mid': ma,
        'lower': lower

Which we can use in the on freqtrade/user_data/strategies/, for this example let’s copy the and re-name it to

Open, modify the class name, from class TestStrategy(IStrategy) to class bbrsi(IStrategy), now we want to be able to take profits at roughly 5% to 7%, but we’ll also include different sell parameters. To modify the profit part, we’ll this section of the strategy:

minimal_roi = {
        "40": 0.0,
        "30": 0.01,
        "20": 0.02,
        "0": 0.04


  minimal_roi = {
        "0": 0.07

Modify stoploss = -0.10 to -3.5% so it will be stoploss = -0.035, we’ll be using sell signal, so search for the line use_sell_signal and change from False to True

We need now to modify the populate indicator section, look for the line
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
then proceed to comment all indicators that we won’t use, in this example ADX is not commented so we’ll remove it by adding # in front of dataframe[‘adx’]…; do the same for other indicators, the bollinger bands section should look like this:

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']

And the RSI section should look like this:
dataframe['rsi'] = ta.RSI(dataframe)

Now we’ll look for def populate_buy_trend in order to create the logic behind our algorithm or strategy, as you can see in the picture:

Whoops, this content is for members only. If you have a membership, please log in. If not, you can definitely get access by buying one of our plans! Purchase the essential plan or Purchase the Professional Plan .

We want it to buy if price of the candle before the current candle was outside the bollinger bands AND the new candle close is now inside the bollinger band range AND if RSI < 50, this is how the code looks like (this section of the code has to be inside def populate_buy_trend function:

		(dataframe[‘close’].shift(1)<dataframe[‘bb_lowerband’]) & 
		(dataframe[‘close’] > dataframe[‘bb_lowerband’]) &
		(dataframe[‘rsi’] < 50)
	‘buy’] = 1

To sell we can do different targets, we already do sell at 7% profit as market in the ROI section of the strategy, now we just need to include other sell possibilities, like sell if the candle closes outside of the top bollinger band or if RSI > 60, we put he following code in the def populate_sell_trend function:

		(dataframe[‘close’]>dataframe[‘bb_upperband’]) | 
		(dataframe[‘rsi’] > 60)
	‘sell’] = 1

This is just an example of how to create a simple strategy by looking at the indicators on tradingview, remember to modify them accordingly, to include fail safe options (we’ll speak more about these failsafe options in another post), backtest the strategy and do dry-runs to make sure its profitable, feel free to comment if you have any questions.

  • Servando Garcia
    10:35 AM, August 2019

    Great article, less than an hour after I implemented this strategy. I turned a profit. Thank you

    • CryptoCue
      10:39 AM, August 2019

      Thanks, do know that this might not be profitable in the long run.

Leave a Reply

Your email address will not be published. Required fields are marked *

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Consent to display content from Youtube
Consent to display content from Vimeo
Google Maps
Consent to display content from Google
Consent to display content from Spotify
Sound Cloud
Consent to display content from Sound
Cart Overview