We have decided to give EVERYTHING for free! What are you waiting for?


Sometimes you might find that Talib or qtpylib or your favorite library is missing specific indicators, depending on their complexity it might be really easy to replicate or create them using the respective definition.

Talib or qtpylib do not contain Bollinger Band % so we’re going to create it parting by the definition.


%B = (Current Price - Lower Band) / (Upper Band - Lower Band) 

This means that we need to decide what Price we want to feed, if its close, open, high or low and then proceed to use the other bollinger band parameters to replicate it.

Default BB using qtpylib

bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) 
dataframe['bb_low'] = bollinger['lower']
dataframe['bb_mid'] = bollinger['mid']
dataframe['bb_upper'] = bollinger['upper']

Creating BB %


That should be it, now you should be able to use Bollinger band % by calling dataframe [‘bb_perc’] in the respective section.

As you can see, the numbers do match with Tradingview default BB %, check the date and the daily candle on BTCUSDT Binance to compare with the screenshot below:

BB% test
BB test

Leave a Reply

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