Bollinger Band RSI Rolling Trading Algorithm (Patreon)
Downloads
Content
Introduction
Welcome to this first post (which will probably be one of many to come) where I discuss a trading algorithm that I found on the Internet (In a Github repo to be precise). I have tested a lot of trading algo's I collected over the years (more on that later) during the last couple of weeks, so that I have some feeding ground for my future posts and/or video's about them.
However, this algorithm performed so poorly that I decided not to create a Youtube for it, but instead only make a relatively short post on Patreon for it.
The main reason is that I just don't want to spend a lot of time investigating and analyzing a trading algorithm that is actually not worth it. If I would also create a Youtube for it (which is pretty intensive work), which also gets not a lot of exposure, then that time has been lost forever. I only want to invest my (and your!) precious time in algo's that have a good probability to make us money in the future. So let's not waste any more of it...
The source
I have said in the past that a lot of the algo's I have were hoarded in the past from different Github repositories. Back then I did not have the idea to make these posts and so did not write down the sources where I got these from. Please excuse me for that.
However, sometimes the author has put his name into the code (for which I am thankfull) so that we can give all kudo's to the actual person that create this for us. I am just the guy who tested the algo and publish the results of it to my audience...
The trading algorithm / strategy
This strategy is a very simple one and does not consist of a lot of code. So it is very simple to explain.
In this case the author of the code is Michael Fourie and his actual statement of his algo is:
This strategy uses Bollinger Bands and the rolling rsi to determine when it should make a buy. Selling is completley determined by the minimal roi.
The author has decided to make use of many ROI points where to exit:
# Minimal ROI designed for the strategy. # This has been determined through hyperopt in a timerange of 270 days. minimal_roi = { "0": 0.03279, "259": 0.02964, "536" : 0.02467, "818": 0.02326, "965": 0.01951, "1230": 0.01492, "1279" : 0.01502, "1448": 0.00945, "1525" : 0.00698, "1616": 0.00319, "1897" : 0 }
And uses a max stoploss of 8 percent to exit bad trades:
# Optimal stoploss designed for the strategy stoploss = -0.08
Finally, he has decided/found out, that the best timeframe for this algo is the 5 minute timeframe.
# Optimal timeframe for the strategy timeframe = '5m'
In the Indicators section the, already announced, Bollinger Band and RSI indicator are programmed.
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) # Bollinger bands 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 his buy and sell conditions are as follows:
Buy when the rolling rsi is below 37 AND then the candle close is below the lower bollinger band.
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( (dataframe['rsi'].rolling(8).min() < 37) & (dataframe['close'] < dataframe['bb_lowerband']) ), 'buy'] = 1 return dataframe
And the sell conditions are determined by the ROI as already stated.
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( ), 'sell'] = 1 return dataframe
So this is the complete strategy code.
Backtest results
As you can see by looking at the results table, the 5 minute timeframe indeed has the best results.
But they also are the best results from the poorest performances over all timeframes...
The strategy did have a good (albeit late) run up to over max 3500 USDT. But probably after the first run up during the last bull market, the performance collapsed and never recovered anymore.
However, the algo did have a winpercentage of 70.16 percent. But taking into consideration that all these small ROI based wins did not match up to less, but higher valued stoploss moments, then overall performance will decline when the markets turn bearish.
Which then result in a humongous drawdown of 94 percent...
Espacially the third week in May gives a particularly devastating blow to this algo's performance.
From which it would never recover again.
Meanwhile always have a porisite winrate over the complete backtesting period. Which is not what you expect to see...
Strategy League
So eventually, this algo ends up failing while having a 'well known' trading idea where the dips are bought and having good winrates.
And this shows in the results of all the algo's performance indicators too.
So in the end it gets one of the lowest position in the total strategy league and it has the 'honor' to be the first of the bad negative trading algorithms. Of which there are not much of at the moment.
There is probably only one way to make this simple strategy more profitable, and that is to optimize the ROI and Stoploss settings by doing a Hyperopt run.
But since that is somewhat of a 'cheat' because it will curve fit this strategies performance over the past data and that will give no guarantee whatsoever that it will do its job in the future.
The end
So my conclusion is to leave this trading idea behind and continue with the next one I tested during the last couple of weeks.
I will leave all the backtest results, plots, strategy code and other output as a download in this post.
Thank you for reading and I will see you in the next post or video.
Goodbye!