Home Creators Posts Import Register Favorites Logout

Content

Introduction

Sometimes you come accross a strategy that does not perform great on the dataset and assets you include in your backtest methodology. No matter if you optimize it or not.

This time I come across such a algo strategy.

Finding the best algo is not only a matter of creating a hypothesis on what to do under which circumstances. It is also a matter of testing if your hypothesis is correct. And if it is not, then abandon your idea and move on to the next.

The quickie algo strategy is such a example for me under my specific setup. Up front I can tell you that this strategy does not perform well. So you can leave this article after I have said this, or read till the end what happened and see where it ends up in the total league. For the Youtube algorithm I hope that you watch until the end, but I am also not so mean to keep you here and waste your precious time. Unless you want to learn something from this post. Then I recommend you stay.

I’ll leave it up to you.

The strategy

And for the people that want to learn something from the author of this specific strategy (which is Gert Wohlgemuth by the way). Let me start from the top and work my way to the bottom of this code.

# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
# --------------------------------
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib

First of all we start with the importing of the necessary modules. Which is followed by the strategy class and the mandatory settings for each python strategy file that is used by the Freqtrade bot.

class Quickie(IStrategy):
"""
author@: Gert Wohlgemuth
idea:
momentum based strategie. The main idea is that it closes trades very quickly, while avoiding excessive losses. Hence a rather moderate stop loss in this case
"""
INTERFACE_VERSION: int = 3
# Minimal ROI designed for the strategy.
# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {
"100": 0.01,
"30": 0.03,
"15": 0.06,
"10": 0.15,
}
# Optimal stoploss designed for the strategy
# This attribute will be overridden if the config file contains "stoploss"
stoploss = -0.25
# Optimal timeframe for the strategy
timeframe = '5m'

The roi is set up to take profits is certain gains are reached after specific amounts of time.

So in this case the bot will sell if after ten minutes a profit of 15 percent is reached and when the time proceeds it ends up demanding lower gains. After 100 minutes of an open trade the strategy is also happy to close the position if there is only a gain of 1 percent reached.

Stop loss has been set to sell if 25 percent loss has been reached on the trade.

And the author has determined that this strategy performs best on the 5 minute timeframe. Which I’ll check later.

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
macd = ta.MACD(dataframe)
dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
dataframe['sma_200'] = ta.SMA(dataframe, timeperiod=200)
dataframe['sma_50'] = ta.SMA(dataframe, timeperiod=200)
dataframe['adx'] = ta.ADX(dataframe)
# required for graphing
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
dataframe['bb_lowerband'] = bollinger['lower']
dataframe['bb_middleband'] = bollinger['mid']
dataframe['bb_upperband'] = bollinger['upper']
return dataframe

Then the indicators are defined that will be used in this strategy.

First of all, the ever well known MACD is used here. With it’s default settings.

Then, the tripple EMA is used here. Which I have not seen being used up until now.

Then the SMA 50 and SMA 200 are defined. But watch closely here, because I see that both timeperiods here have 200 defined.

The ADX is being used, without the DI+ and DI-.

And finally the Bollinger bands are used with its default values.

def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['adx'] > 30) &
(dataframe['tema'] < dataframe['bb_middleband']) &
(dataframe['tema'] > dataframe['tema'].shift(1)) &
(dataframe['sma_200'] > dataframe['close'])
),
'enter_long'] = 1
return dataframe

For the buy signal to be valid, a couple of indicators should have the following conditions:

  • The adx should be above 30
  • And the TEMA should be below the bollinger middle band
  • Also the current TEMA value should be bigger than the previous one, which indicates a rising line
  • And finally the SMA 200 should be bigger then the current candle close

As you can see, the SMA 50 is not used here, as well as the MACD by the way.

def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['adx'] > 70) &
(dataframe['tema'] > dataframe['bb_middleband']) &
(dataframe['tema'] < dataframe['tema'].shift(1))
),
'exit_long'] = 1
return dataframe

For the sell signal the following conditions should be met:

  • The ADX should be above 70 and
  • the TEMA should be above the Bollinger middle band
  • and the current TEMA value should be lower of that of its previous value. So a declining line in this case.

Furthermore I have no clue on the phylosophy of this strategy. My best guess is that it should work under bearish circumstances, hence the close price below the SMA 200. And I guess that the author hopes to buy on even more negative pullbacks and then some positive reversals, which should be closed after the middle Bollinger band is crossed above by the TEMA.

His comment on avoiding excessive losses and using a moderate stop loss does not compute with the 25 percent stop loss setting. Which is rather large.

I am already a little bit scared to test this strategy, but I also have seen some surprising results on other ones that I also did not completely trust. So let’s just continue testing this algo.

Initial backtest results

I was affraid that this algo would not perform great by trying to understanding it’s internal logics and it seems that I have been right this time.

Initial backtest results

Like I told in my Low Bollinger band video, a high winrate only does not say anything. And this is the exact example that proves this point. On all timeframes this algo has over 90 percent winrates but the other scores are just dramatic. Drawdowns of around 90 percent do not occur much and do not give me the confidence that this strategy give me much future profits.

I am not even going to try to analyse the reasons why this occurs and just quickly move on to the optimization part. Maybe my opinion changes after seeing the results after that…

Hyperparameter optimizing

When I see that the optimized settings perform even worse, I get the feeling that this post is going to be short.

And indeed, even after optimizing, this strategy performs even worse.

Now I must say honestly that I had to turn down the amount of epochs to only 100 because otherwise my computer could not handle the optimization after that. Memory problems and such. Already familiar stuff for those who watched my earlier video’s.

The 5 minute timeframe is just a hard timeframe to optimize and until now, a lot of the strategies on that timeframe are not spectacularly improved by hyperparameter optimization until so far.

Plots

Also, and again, plots that take up over 1 gigabyte of harddrive space are just too big to open. And I wonder if I could really see anything in a chart that spans over three years and contain over 11000 trades.

If you really want to analyze what’s going wrong with this algorithm, then it’s better you take a small timerange and test that out to see what happens. Maybe you can extrapolate to larger timespans and find out how to improve this.

The strategy league

So, I admint that this is one of my lesser spectacular posts and I am sorry that I cannot provide you with the ultimate trading strategy that will make you buy your first Lamborghini.

But If you have sat this post out, out of curiousity on where this strategy would end in the strategy league, then I will quickly show you were it enters the league:

And that is the third place from the bottom. So you see, you cannot win them all and expect to have even more spectacular results each and every time. This is also part of life. And I still have results because I have tested yet another algorithmic trading strategy from the Freqtrade repository.

And for those readers that stayed till the end: I really admire your patience and resillience. Character building is done under bad times. This will show you that you will also make it through other bearish conditions. And at some point your hard work will be rewarded.

Thank you and I will see you in the next post!

Files

As always, the output from these tests and hyperopts will be available as addendums on my Patreon page for my supporters. There, I will leave a compressed file with the complete output of the tests I write about or show in my youtube video’s. With these files you can analyse my output or compare my results with tests on your own setup.

If you like this content and want to support me by buying a cup of coffee or a sandwich once in a while, then become a patron. I will also add additional content about the interesting field of algorithmic trading with automatic trading bots over there as well.So this way I can provide you with some additional benefits as well.

Thank you for visiting!!

Comments

No comments found for this post.