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 *

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