Bollinger Bands Trading Bot Development

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Bollinger Bands Trading Bot Development
Simple
~3-5 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1214
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Bollinger Bands Trading Bot Development

Bollinger Bands is a volatility indicator developed by John Bollinger. Three lines: middle (SMA 20) and two bands at distance of N standard deviations (usually 2). 95% of the time price is within bands. Exiting the band is a statistically significant event.

Strategy Logic

Mean-reversion approach: price exits below lower band → oversold → buy expecting return to average.

Breakout approach: price breaks upper band with high volume → trend continuation → buy.

Important not to mix these two approaches in one bot without market regime filter.

Implementation

import pandas_ta as ta
import ccxt

class BollingerBandsBot:
    def __init__(self, symbol: str, period: int = 20, std_dev: float = 2.0):
        self.exchange = ccxt.bybit({'apiKey': API_KEY, 'secret': SECRET})
        self.symbol = symbol
        self.period = period
        self.std_dev = std_dev
    
    async def get_signal(self) -> str:
        ohlcv = await self.exchange.fetch_ohlcv(self.symbol, '1h', limit=100)
        df = pd.DataFrame(ohlcv, columns=['ts','open','high','low','close','vol'])
        
        # Calculate Bollinger Bands
        bb = ta.bbands(df['close'], length=self.period, std=self.std_dev)
        
        lower = bb[f'BBL_{self.period}_{self.std_dev}'].iloc[-1]
        mid   = bb[f'BBM_{self.period}_{self.std_dev}'].iloc[-1]
        upper = bb[f'BBU_{self.period}_{self.std_dev}'].iloc[-1]
        price = df['close'].iloc[-1]
        
        # Bandwidth — band width normalized to average
        bandwidth = (upper - lower) / mid
        
        # Mean-reversion only when low volatility (squeeze)
        if bandwidth < 0.04:  # band is narrow — prepare for breakout
            return 'WATCH'
        
        if price < lower:
            return 'BUY'   # below lower band
        elif price > upper:
            return 'SELL'  # above upper band
        
        # Return to average — exit position
        if abs(price - mid) / mid < 0.002:  # price at average
            return 'CLOSE'
        
        return 'HOLD'

%B and Bandwidth

%B shows where price is within the band (0 = lower band, 1 = upper band):

percent_b = (price - lower) / (upper - lower)
# < 0: below lower (oversold)
# > 1: above upper (overbought)
# 0.5: at middle line

Bandwidth (band width) is a volatility indicator. "Bollinger Squeeze" — strong narrowing often precedes sharp move. Signal direction — from first breakout after squeeze.

Bot based on Bollinger Bands with mean-reversion logic and bandwidth filter is developed in 1–2 weeks.