avatarMichael King

Summarize

Bollinger Bands Indicator — Day Trading Strategies for Crypto Coins with Python by using Binance Data

Hello fellow crypto traders! Today, I want to talk about a powerful technical analysis tool that can help you make informed decisions in your crypto day trading — Bollinger Bands Indicator. For those who are unfamiliar with it, Bollinger Bands is a volatility indicator that consists of a simple moving average and two standard deviation lines above and below it.

Midjourney prompted by Michael King

In this article, I will guide you through the process of implementing Bollinger Bands Indicator in your day trading strategies for crypto coins using Python and Binance data. Whether you are a beginner or an experienced trader, I believe that you will find this article both informative and valuable. So, get ready and dive into the world of Bollinger Bands Indicator!

Disclaimer: Please note that I am not a professional trading advisor, and the information provided in this article is based on my personal experience and opinions. The crypto market is highly volatile and subject to unpredictable changes, and there is a risk of losing your investment. Please do your own research and seek professional advice before making any investment decisions. The information presented in this article should not be treated as investment advice, and all readers are responsible for their own investment decisions.

Bollinger Bands Basics

Bollinger Bands were created by John Bollinger in the 1980s, and they have become an essential tool for many traders in various financial markets, including the crypto market. Bollinger Bands measure the volatility of an asset by plotting the standard deviation lines above and below the moving average. These bands will expand when the price of an asset becomes more volatile, and they will contract when the price becomes less volatile.

In this article, I will be using two specific signals from Bollinger Bands — Bollinger Bands Percent (BBP) and Bollinger Band Width (BBW) — as my indicators for a trading simulation. BBP measures where the current price is relative to the Bollinger Bands, while BBW measures the distance between the upper and lower bands. By combining these signals, we can create a strategy that can help us identify potential buying and selling opportunities in the crypto market.

In my view, there is one small issue with using the standard BBW as a signal for automated algotrading. The standard BBW uses an absolute scale, which means that its value differs wildly from coin to coin. This makes it difficult to use as a trigger for automated trading.

To overcome this issue, I’ve decided to use a modified version of the BBW indicator, which I call BBW_Ratio. BBW_Ratio is calculated as the ratio between the current BBW value and the rolling average BBW value. This provides a universal tool that can be applied to any cryptocurrency, regardless of its volatility or market capitalization.

By using BBW_Ratio, we can compare the current state of the Bollinger Bands for each cryptocurrency in a consistent and meaningful way. This will allow us to create a trading strategy that is not only more robust but also more flexible, as it can be applied to a wide range of cryptocurrencies.

Let’s check the SOLUSDT chart example below.

Bollinger Bands: Recent SOLUSDT pump (pay attention to the large bump of the yellow line)

As you can see a strong price momentum was indicated by a massive BBW bump, and BBP was greater than 1. And I would love to capture this price pump somehow. And for that reason I’m using BBW_Ratio on my next chart example.

Bollinger Bands: Recent SOLUSDT pump (use of BBW ratio)

BUY signal triggered by BBP > 1 AND BBW_ratio > 1.75 SELL signal triggered by BBP < 0.5 AND BBW_ratio < 1.5

Bollinger Bands: Recent SOLUSDT pump (use of BBW ratio) (scaled BB indicators)

Trading Simulation Prerequisites

I will be utilizing several Python modules, including python-binance, pandas, pandas-ta, and matplotlib. These modules are essential tools for traders and offer a wealth of functionality for data analysis and visualization.

To install these modules, you can simply run the following command in your terminal or command prompt:

pip install python-binance pandas pandas-ta matplotlib

Foundations

I have decided to use Binance trading data for the top 20 cryptocurrencies based on their market cap. The data range I have chosen covers the last 100 days and I will be using 30-minute candle intervals to calculate technical indicators.

The assumption of the tests is that I’m spending the same amount of money on each BUY action (let’s say 100 dollars)

First Test

Test parameters:

bb_lengths = [10, 15, 20]
rolling_ranges = [5, 10, 15]
buy_limits_bbw_ratio = [1.3, 1.5, 1.8]  # BUY SIGNAL if the indicated value is crossed in positive direction
buy_limits_bbp = [1]  # BUY SIGNAL if the indicated value is crossed in positive direction
sell_limits_bbw_ratio = [1] # SELL SIGNAL if the indicated value is crossed in negative direction
sell_limits_bbp = [0.5] # SELL SIGNAL if the indicated value is crossed in negative direction
loss_stop_in_percent = -5

Python script:

import pandas as pd
import matplotlib.pyplot as plt
import time
import pandas_ta as pta
from binance.client import Client
from pprint import pprint
api_key = "YOUR_BINANCE_API_KEY"
api_secret = "YOUR_BINANCE_API_SECRET"
client = Client(api_key, api_secret)
def get_data_frame(symbol='BTCUSDT', period='30m', timeframe='1 hours ago UTC'):
    try:
        bars = client.get_historical_klines(symbol, period, timeframe)
    except Exception as e:
        print('GET Data error', symbol)
        print(e)
        time.sleep(5)
        bars = client.get_historical_klines(symbol, period, timeframe)
    for line in bars:
        del line[7:]
    df = pd.DataFrame(bars, columns=['open_time', 'open',
                                     'high', 'low', 'close',
                                     'volume', 'close_time'])
    df['close'] = df['close'].apply(pd.to_numeric)
    df['open'] = df['open'].apply(pd.to_numeric)
    df['high'] = df['high'].apply(pd.to_numeric)
    df['low'] = df['low'].apply(pd.to_numeric)
    df['volume'] = df['volume'].apply(pd.to_numeric)
    df['close_time'] = df['close_time'].apply(pd.to_numeric) / 1000
    return df
top_coins = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'XRPUSDT',
             'ADAUSDT', 'DOGEUSDT', 'MATICUSDT', 'SOLUSDT',
             'DOTUSDT', 'LTCUSDT', 'SHIBUSDT', 'AVAXUSDT',
             'DAIUSDT', 'TRXUSDT', 'UNIUSDT', 'ATOMUSDT',
             'LINKUSDT', 'ETCUSDT', 'XMRUSDT', 'APTUSDT']
trading_data = {}
# retrieve Binance trade data
for coin in top_coins:
    trading_data[coin] = get_data_frame(symbol=coin, period='30m',
                                        timeframe='100 days ago UTC')
# placeholder variable
winner_config = {'profit_ave':False, 'parameters':''}
# Generate trading Signals
bb_lengths = [10, 15, 20]
rolling_ranges = [5, 10, 15]
buy_limits_bbw_ratio = [1.3, 1.5, 1.8]  # BUY SIGNAL if the indicated value is crossed in positive direction
buy_limits_bbp = [1]  # BUY SIGNAL if the indicated value is crossed in positive direction
sell_limits_bbw_ratio = [1] # SELL SIGNAL if the indicated value is crossed in negative direction
sell_limits_bbp = [0.5] # SELL SIGNAL if the indicated value is crossed in negative direction
loss_stop_in_percent = -5
plotting = False
for length in bb_lengths:
    for rolling_range in rolling_ranges:
        # adding trading indicator to the trading data set
        for coin in top_coins:
            try:
                bb_period = length
                bb_std = 2
                bb = pta.bbands(close=trading_data[coin]['close'], length=bb_period, std=bb_std, ddof=0, mamode=None, talib=None, offset=None)
                trading_data[coin]['bbp'] = bb[f'BBP_{bb_period}_{bb_std}.0']
                trading_data[coin]['bbw'] = bb[f'BBB_{bb_period}_{bb_std}.0']
                trading_data[coin]['bbw_rolling_ave'] = trading_data[coin]['bbw'].shift(2).rolling(rolling_range).mean()
                trading_data[coin]['bbw_ratio'] = trading_data[coin]['bbw'] / trading_data[coin]['bbw_rolling_ave']
            except:
                continue
            coin_for_plotting = 'DOGEUSDT'
            if coin == coin_for_plotting and plotting == True:
                fig,ax = plt.subplots()
                fig.subplots_adjust(right=0.75)
                # Primary chart for Close Price
                ax.set_xlabel('time', fontsize=14)
                ax.plot(trading_data[coin_for_plotting].close_time, trading_data[coin_for_plotting].close, color='black', label='close')
                ax.grid(axis="x")
                ax.set_ylabel('close', color='black', fontsize=12)
                ax2 = ax.twinx()
                ax2.plot(trading_data[coin_for_plotting].close_time,
                         trading_data[coin_for_plotting].bbp,
                         color='lightgreen', label='BBP')
                ax2.set_ylabel('BBP', color='black', fontsize=12)
                ax2.set_ylim(bottom=0.5)
                ax3 = ax.twinx()
                ax3.plot(trading_data[coin_for_plotting].close_time,
                         trading_data[coin_for_plotting].bbw_ratio,
                         color='orange', label='BBW_ratio')
                ax3.set_ylim(bottom=1.75)
                ax3.spines.right.set_position(("axes", 1.1))
                ax3.set_ylabel('BBW_ratio', color='black', fontsize=12)
                lines_1, labels_1 = ax.get_legend_handles_labels()
                lines_2, labels_2 = ax2.get_legend_handles_labels()
                lines_3, labels_3 = ax3.get_legend_handles_labels()
                lines = lines_1 + lines_2 + lines_3
                labels = labels_1 + labels_2 + labels_3
                ax.legend(lines, labels, loc=0)
                plt.show()
                quit()
        for buy_limit_bbw in buy_limits_bbw_ratio:
            for buy_limit_bbp in buy_limits_bbp:
                for sell_limit_bbw in sell_limits_bbw_ratio:
                    for sell_limit_bbp in sell_limits_bbp:
                        total_profit = []
                        total_profit_coin_ref = []
                        for coin in top_coins:
                            trading_data[coin]['trading_signal'] = '-'
                            # generate BUY and SELL signals
                            try:
                                trading_data[coin].loc[(trading_data[coin]['bbw_ratio'] > buy_limit_bbw) &
                                                       (trading_data[coin]['bbw_ratio'].shift() < buy_limit_bbw) &
                                                       (trading_data[coin]['bbp'] > buy_limit_bbp) &
                                                       (trading_data[coin]['bbp'].shift() < buy_limit_bbp),
                                                       'trading_signal'] = 'BUY'
                                trading_data[coin].loc[((trading_data[coin]['bbw_ratio'] < sell_limit_bbw) &
                                                       (trading_data[coin]['bbw_ratio'].shift() > sell_limit_bbw)) |
                                                       ((trading_data[coin]['bbp'] < sell_limit_bbp) &
                                                        (trading_data[coin]['bbp'].shift() > sell_limit_bbp)),
                                                       'trading_signal'] = 'SELL'
                            except:
                                continue
                            purchase_price = 0
                            profit_list = []
                            # run trading simulation across the data set and use trading signals as triggers
                            for i in range(len(trading_data[coin])):
                                if trading_data[coin].iloc[i]['trading_signal'] == 'BUY' and purchase_price == 0:
                                    purchase_price = trading_data[coin].iloc[i]['close']
                                if purchase_price != 0:
                                    profit = round(((trading_data[coin].iloc[i]['close'] / purchase_price) * 100) - 100, 2)
                                    # Sell if Profit drops below set limit or trading signal indicates SELL
                                    if trading_data[coin].iloc[i]['trading_signal'] == 'SELL' or profit < loss_stop_in_percent:
                                        if profit < loss_stop_in_percent:
                                            profit = loss_stop_in_percent
                                        profit_list.append(profit)
                                        purchase_price = 0
                            total_profit.append(round(sum(profit_list),2))
                            total_profit_coin_ref.append(f'{coin} {round(sum(profit_list),2)}%')
                        if winner_config['profit_ave'] == False:
                            winner_config['profit_ave'] = round(sum(total_profit)/len(total_profit),2)
                            winner_config['parameters'] = f'BB Parameters: LENGTH: {length}, ' \
                                                          f'BUY: BBB_ratio: {buy_limit_bbw} BBP: {buy_limit_bbp}, \tSELL: BBB_ratio: {sell_limit_bbw} BBP: {sell_limit_bbp}, ' \
                                                          f'Rolling_range {rolling_range}'
                        elif round(sum(total_profit)/len(total_profit),2) > winner_config['profit_ave']:
                            winner_config['profit_ave'] = round(sum(total_profit) / len(total_profit), 2)
                            winner_config['parameters'] = f'BB Parameters: LENGTH: {length}, ' \
                                                          f'BUY: BBB_ratio: {buy_limit_bbw} BBP: {buy_limit_bbp}, \tSELL: BBB_ratio: {sell_limit_bbw} BBP: {sell_limit_bbp}, ' \
                                                          f'Rolling_range {rolling_range}'
                        print(f'Overall Average Profit: {round(sum(total_profit)/len(total_profit),2)}%, '
                              f'BB Parameters: LENGTH: {length}, BUY: BBB_ratio: {buy_limit_bbw} BBP: {buy_limit_bbp}, \tSELL: BBB_ratio: {sell_limit_bbw} BBP: {sell_limit_bbp}, Rolling_range {rolling_range}'
                              f'\nDetails: {total_profit_coin_ref}\n')
print(f'WINNER! with average profit {winner_config["profit_ave"]}%')
print(winner_config['parameters'])

Output:

---
Truncated output... feel free to run it yourself for more details
---
Overall Average Profit: 3.27%, BB Parameters: LENGTH: 20, BUY: BBB_ratio: 1.5 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 10
Details: ['BTCUSDT 10.9%', 'ETHUSDT 11.1%', 'BNBUSDT -6.47%', 'XRPUSDT 1.27%', 'ADAUSDT 3.53%', 'DOGEUSDT -9.47%', 'MATICUSDT 1.42%', 'SOLUSDT 10.12%', 'DOTUSDT -7.33%', 'LTCUSDT -10.1%', 'SHIBUSDT -13.18%', 'AVAXUSDT 34.68%', 'TRXUSDT -4.9%', 'UNIUSDT -2.71%', 'ATOMUSDT 4.66%', 'LINKUSDT -6.27%', 'ETCUSDT -9.67%', 'XMRUSDT 7.12%', 'APTUSDT 47.47%']
Overall Average Profit: 0.14%, BB Parameters: LENGTH: 20, BUY: BBB_ratio: 1.8 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 10
Details: ['BTCUSDT 11.37%', 'ETHUSDT 0.81%', 'BNBUSDT -10.39%', 'XRPUSDT 0.69%', 'ADAUSDT -3.66%', 'DOGEUSDT -10.73%', 'MATICUSDT 0.77%', 'SOLUSDT -1.73%', 'DOTUSDT 3.63%', 'LTCUSDT -0.43%', 'SHIBUSDT -4.86%', 'AVAXUSDT 20.21%', 'TRXUSDT 0.43%', 'UNIUSDT -1.63%', 'ATOMUSDT 1.34%', 'LINKUSDT -5.41%', 'ETCUSDT -12.82%', 'XMRUSDT -0.34%', 'APTUSDT 15.37%']
Overall Average Profit: 5.61%, BB Parameters: LENGTH: 20, BUY: BBB_ratio: 1.3 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 13.63%', 'ETHUSDT 7.41%', 'BNBUSDT 0.88%', 'XRPUSDT 8.56%', 'ADAUSDT 4.03%', 'DOGEUSDT -2.34%', 'MATICUSDT 1.89%', 'SOLUSDT 37.54%', 'DOTUSDT -15.7%', 'LTCUSDT 8.32%', 'SHIBUSDT -2.08%', 'AVAXUSDT 24.41%', 'TRXUSDT 12.91%', 'UNIUSDT -5.02%', 'ATOMUSDT 0.23%', 'LINKUSDT 11.47%', 'ETCUSDT -4.25%', 'XMRUSDT 0.2%', 'APTUSDT 4.41%']
Overall Average Profit: 3.45%, BB Parameters: LENGTH: 20, BUY: BBB_ratio: 1.5 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 13.12%', 'ETHUSDT 18.37%', 'BNBUSDT -9.12%', 'XRPUSDT -2.66%', 'ADAUSDT -0.07%', 'DOGEUSDT -5.82%', 'MATICUSDT 10.01%', 'SOLUSDT 7.29%', 'DOTUSDT -6.87%', 'LTCUSDT -0.06%', 'SHIBUSDT -14.6%', 'AVAXUSDT 21.35%', 'TRXUSDT 0.32%', 'UNIUSDT 9.62%', 'ATOMUSDT -3.59%', 'LINKUSDT -8.73%', 'ETCUSDT -7.65%', 'XMRUSDT 7.83%', 'APTUSDT 36.9%']
Overall Average Profit: -0.59%, BB Parameters: LENGTH: 20, BUY: BBB_ratio: 1.8 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 5.54%', 'ETHUSDT 0.15%', 'BNBUSDT -5.35%', 'XRPUSDT -3.4%', 'ADAUSDT -7.77%', 'DOGEUSDT -6.43%', 'MATICUSDT -4.81%', 'SOLUSDT 5.18%', 'DOTUSDT -7.28%', 'LTCUSDT -2.8%', 'SHIBUSDT -7.78%', 'AVAXUSDT 23.33%', 'TRXUSDT -2.34%', 'UNIUSDT -1.14%', 'ATOMUSDT 7.19%', 'LINKUSDT -9.79%', 'ETCUSDT -14.42%', 'XMRUSDT 6.09%', 'APTUSDT 14.63%']
WINNER! with average profit 9.26%
BB Parameters: LENGTH: 15, BUY: BBB_ratio: 1.3 BBP: 1,  SELL: BBB_ratio: 1 BBP: 0.5, Rolling_range 15

WINNER! with average profit: 9.26%

BB Parameters: LENGTH: 15, BUY: BBW_ratio: 1.3 BBP: 1, SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15

Second Test:

I’m wondering if 30 minutes intervals are a bit too course for Bollinger Bands trading strategy, let’s rerun the test with 15 minutes interval (same BB parameters)

Output:

---
Truncated output... feel free to run it yourself for more details
---
Overall Average Profit: 0.37%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.5 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 10
Details: ['BTCUSDT -2.83%', 'ETHUSDT -6.86%', 'BNBUSDT -1.61%', 'XRPUSDT 0.66%', 'ADAUSDT -13.47%', 'DOGEUSDT 17.61%', 'MATICUSDT 24.72%', 'SOLUSDT -19.64%', 'DOTUSDT -5.61%', 'LTCUSDT 5.82%', 'SHIBUSDT -3.87%', 'AVAXUSDT 8.33%', 'TRXUSDT 0.06%', 'UNIUSDT -13.36%', 'ATOMUSDT -2.42%', 'LINKUSDT 7.97%', 'ETCUSDT 10.7%', 'XMRUSDT -1.03%', 'APTUSDT 1.85%']
Overall Average Profit: -3.52%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.8 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 10
Details: ['BTCUSDT 0.13%', 'ETHUSDT -6.66%', 'BNBUSDT -7.12%', 'XRPUSDT -2.67%', 'ADAUSDT -7.03%', 'DOGEUSDT -2.41%', 'MATICUSDT 16.89%', 'SOLUSDT -6.54%', 'DOTUSDT -12.21%', 'LTCUSDT 4.04%', 'SHIBUSDT 2.22%', 'AVAXUSDT 3.12%', 'TRXUSDT -6.67%', 'UNIUSDT -6.46%', 'ATOMUSDT -14.32%', 'LINKUSDT -4.79%', 'ETCUSDT -5.41%', 'XMRUSDT 0.3%', 'APTUSDT -11.33%']
Overall Average Profit: 3.0%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 2.3%', 'ETHUSDT 6.93%', 'BNBUSDT 1.45%', 'XRPUSDT 18.28%', 'ADAUSDT 15.75%', 'DOGEUSDT -6.31%', 'MATICUSDT 2.31%', 'SOLUSDT 18.26%', 'DOTUSDT -11.24%', 'LTCUSDT -1.19%', 'SHIBUSDT -9.9%', 'AVAXUSDT 30.88%', 'TRXUSDT 4.79%', 'UNIUSDT -6.61%', 'ATOMUSDT -3.05%', 'LINKUSDT -4.34%', 'ETCUSDT 13.35%', 'XMRUSDT -8.36%', 'APTUSDT -6.23%']
Overall Average Profit: 0.24%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.5 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 7.5%', 'ETHUSDT -2.74%', 'BNBUSDT -5.7%', 'XRPUSDT -3.48%', 'ADAUSDT -7.14%', 'DOGEUSDT -12.57%', 'MATICUSDT 28.78%', 'SOLUSDT -14.54%', 'DOTUSDT -5.75%', 'LTCUSDT 10.45%', 'SHIBUSDT -7.12%', 'AVAXUSDT 36.88%', 'TRXUSDT -12.56%', 'UNIUSDT -6.1%', 'ATOMUSDT -0.66%', 'LINKUSDT -7.62%', 'ETCUSDT 11.24%', 'XMRUSDT -10.47%', 'APTUSDT 6.25%']
Overall Average Profit: -1.34%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.8 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 0.8%', 'ETHUSDT 0.51%', 'BNBUSDT -6.56%', 'XRPUSDT 3.64%', 'ADAUSDT -0.58%', 'DOGEUSDT -1.61%', 'MATICUSDT 11.6%', 'SOLUSDT 16.14%', 'DOTUSDT -16.46%', 'LTCUSDT 4.76%', 'SHIBUSDT -5.19%', 'AVAXUSDT 19.85%', 'TRXUSDT -13.01%', 'UNIUSDT -8.4%', 'ATOMUSDT -13.12%', 'LINKUSDT -5.63%', 'ETCUSDT 6.31%', 'XMRUSDT 1.74%', 'APTUSDT -20.16%']
WINNER! with average profit 5.14%
BB Parameters: LENGTH: 10, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15

WINNER! with average profit: 5.14%

BB Parameters: LENGTH: 10, BUY: BBW_ratio: 1.3 BBP: 1, SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15

Looks like smaller interval has decreased my average profit… not good…

Third Test

Let’s test it with 1h interval and see how the profit will look like.

Output:

---
Truncated output... feel free to run it yourself for more details
---
Overall Average Profit: 4.86%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 0.99%', 'ETHUSDT 4.63%', 'BNBUSDT -6.09%', 'XRPUSDT 3.23%', 'ADAUSDT -1.62%', 'DOGEUSDT -4.54%', 'MATICUSDT 13.32%', 'SOLUSDT 8.84%', 'DOTUSDT -2.78%', 'LTCUSDT 6.45%', 'SHIBUSDT -8.69%', 'AVAXUSDT 7.35%', 'TRXUSDT 9.72%', 'UNIUSDT -3.19%', 'ATOMUSDT 2.17%', 'LINKUSDT 12.0%', 'ETCUSDT -1.14%', 'XMRUSDT -2.14%', 'APTUSDT 53.8%']
Overall Average Profit: 3.91%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.5 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT -1.85%', 'ETHUSDT 7.58%', 'BNBUSDT -1.1%', 'XRPUSDT 2.48%', 'ADAUSDT 3.02%', 'DOGEUSDT -8.09%', 'MATICUSDT 10.02%', 'SOLUSDT -1.92%', 'DOTUSDT 22.62%', 'LTCUSDT 10.47%', 'SHIBUSDT -9.07%', 'AVAXUSDT 10.66%', 'TRXUSDT 0.9%', 'UNIUSDT -5.12%', 'ATOMUSDT 8.72%', 'LINKUSDT 7.32%', 'ETCUSDT -6.66%', 'XMRUSDT -3.34%', 'APTUSDT 27.74%']
Overall Average Profit: 4.85%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.8 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 1.32%', 'ETHUSDT 0.52%', 'BNBUSDT -1.23%', 'XRPUSDT 1.58%', 'ADAUSDT 4.02%', 'DOGEUSDT 6.87%', 'MATICUSDT 8.05%', 'SOLUSDT -2.89%', 'DOTUSDT 7.21%', 'LTCUSDT 11.49%', 'SHIBUSDT -1.56%', 'AVAXUSDT 9.99%', 'TRXUSDT 1.93%', 'UNIUSDT 1.72%', 'ATOMUSDT -0.41%', 'LINKUSDT -2.62%', 'ETCUSDT 16.96%', 'XMRUSDT -4.16%', 'APTUSDT 33.31%']
WINNER! with average profit 10.7%
BB Parameters: LENGTH: 15, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 5

WINNER! with average profit 10.7%

BB Parameters: LENGTH: 15, BUY: BBW_ratio: 1.3 BBP: 1, SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 5

that is better, and I’m wondering if 2h interval will make even bigger impact

Final Test

Let’s test it with 2h interval

Output:

---
Truncated output... feel free to run it yourself for more details
---
Overall Average Profit: 2.26%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.8 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 10
Details: ['BTCUSDT -1.07%', 'ETHUSDT 4.12%', 'BNBUSDT -0.77%', 'XRPUSDT 0%', 'ADAUSDT 0%', 'DOGEUSDT -5%', 'MATICUSDT -4.1%', 'SOLUSDT 37.33%', 'DOTUSDT 1.48%', 'LTCUSDT 19.5%', 'SHIBUSDT -14.36%', 'AVAXUSDT 5.28%', 'TRXUSDT 0%', 'UNIUSDT 0%', 'ATOMUSDT 2.3%', 'LINKUSDT 0%', 'ETCUSDT 0%', 'XMRUSDT -1.85%', 'APTUSDT 0%']
Overall Average Profit: 2.21%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT 5.97%', 'ETHUSDT 4.62%', 'BNBUSDT -1.58%', 'XRPUSDT 0%', 'ADAUSDT -1.86%', 'DOGEUSDT -9.55%', 'MATICUSDT 28.47%', 'SOLUSDT 10.34%', 'DOTUSDT 6.58%', 'LTCUSDT 14.69%', 'SHIBUSDT -11.82%', 'AVAXUSDT 3.91%', 'TRXUSDT 1.35%', 'UNIUSDT 0.0%', 'ATOMUSDT 7.36%', 'LINKUSDT -6.48%', 'ETCUSDT -1.49%', 'XMRUSDT -2.57%', 'APTUSDT -5.89%']
Overall Average Profit: 3.2%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.5 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT -0.14%', 'ETHUSDT -3.24%', 'BNBUSDT -1.58%', 'XRPUSDT 0%', 'ADAUSDT -3.13%', 'DOGEUSDT -4.82%', 'MATICUSDT 28.15%', 'SOLUSDT 29.98%', 'DOTUSDT 0.89%', 'LTCUSDT 16.69%', 'SHIBUSDT -9.36%', 'AVAXUSDT 0.45%', 'TRXUSDT 0%', 'UNIUSDT 0%', 'ATOMUSDT 14.14%', 'LINKUSDT -1.64%', 'ETCUSDT -4.64%', 'XMRUSDT 0%', 'APTUSDT -0.89%']
Overall Average Profit: 1.8%, BB Parameters: LENGTH: 20, BUY: BBW_ratio: 1.8 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 15
Details: ['BTCUSDT -0.02%', 'ETHUSDT 1.35%', 'BNBUSDT 1.43%', 'XRPUSDT -1.87%', 'ADAUSDT -0.21%', 'DOGEUSDT -8.3%', 'MATICUSDT 8.9%', 'SOLUSDT 33.34%', 'DOTUSDT -5.79%', 'LTCUSDT 16.63%', 'SHIBUSDT -14.36%', 'AVAXUSDT 3.91%', 'TRXUSDT 0.18%', 'UNIUSDT 0.78%', 'ATOMUSDT 5.35%', 'LINKUSDT 0%', 'ETCUSDT -5%', 'XMRUSDT -2.13%', 'APTUSDT 0%']
WINNER! with average profit 15.81%
BB Parameters: LENGTH: 10, BUY: BBW_ratio: 1.3 BBP: 1,  SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 5

WINNER! with average profit 15.81%

BB Parameters: LENGTH: 10, BUY: BBW_ratio: 1.3 BBP: 1, SELL: BBW_ratio: 1 BBP: 0.5, Rolling_range 5

Indeed, longer intervals seems to work better with Bollinger Bands strategy!

I hope that this article has given you a good introduction to the world of Bollinger Bands Indicator and how it can be used in your crypto day trading. By combining BBP and BBW_Ratio, we can create a robust and flexible strategy that can help us identify potential buying and selling opportunities in the crypto market.

If you enjoyed this article and want to learn more about technical analysis and algo trading in the crypto market, I encourage you to follow my channel and join my newsletter. I will be sharing more articles, tutorials, and trading simulations in the future, and you won’t want to miss out!

So, thank you for reading this article and I hope to see you again soon! Let’s continue to grow and learn together in the exciting world of crypto trading.

PS: in my next trading strategy test I will be focusing on Vortex Indicator. Stay tuned!

Photo by Fahmi Fakhrudin on Unsplash
Technology
Binance
Cryptocurrency
Algorithmic Trading
Python
Recommended from ReadMedium