The simple strategy - Is it profitable or not?

The ‘Simple’ strategy. Is it profitable or not?

By DutchCryptoDad | DutchCryptoDad | 9 Feb 2022


Intro

Hi there and welcome to this blog series where I will be searching for the best trading strategy for cryptocurrency trading. In each blogpost I am going to test a strategy that is explained in a youtube video, trading site or is publicly available for use.

Each strategy will be tested on its performance by trading multiple digital asset pairs over their largest possible backtest period. The result of this test is then compared with the results of earlier tested strategies. 

If you like these articles and you want to see how I execute these tests, then see the video that I included in this post.

Please remember that this post is for entertainment and educational purposes only. I am not a professional, so always do your own research before using any information in real trading.

In this post I will test a strategy that is freely available for use in the Freqtrade github site under the strategies repository.

These strategies are all developed by Gert Wohlgemuth, so all credits go to him for making these.

In an earlier video I tested another strategy of his and I got some very interesting results. So I wanted to test some more of his strategies to see If they produce similar or even better results.

In this video I am going to test his Simple strategy and according to his code this strategy is based on a book called “The simple strategy”. I do not know if the code exactly represents the strategy of this book. So to be on the safe side I assume that this code partially uses the strategy and is not an exact replication of it. Coincidentally I also tested another strategy of this author in an earlier video

The setup

See this blog post to know more about the approach I use when making these backtests: https://www.publish0x.com/dutchcryptodad/is-it-profitable-or-not-the-setup-and-approach-xppgjoj

Strategy

If I take a look at the code I see that the strategy apparently has a 5 minute timeframe and makes use of the RSI, MACD and Bollinger bands.

8d8ab7413f7bf736e4584618ba48159ed4b8d30669a6efc5fa1c1332e65ddb6e.png

I Suggest that you read up on these indicators to know what they do and how to apply them to your strategy. You can find all the information on the Internet about them. There are a lot of  resources on the internet about these indicators so there is no reason not to read up on them.

The code

d0be2023123dcb073b5bb8bb9a40b8a6cfaa3aa4f394cc679729815091988470.png

As you can see the strategy has a takeprofit point of 1% profit and a stoploss setting which sells at 25% loss.

BUY signal

  • The buy signal happens when the macd is above 0
  • And macd is above the macd signal line
  • Also the bollinger upperband of the current candle should be higher than the bollinger upperband of the previous candle. This indicates a rising price.
  • Finally the last condition is that the RSI should be above 70

If all these conditions are met, then a buy signal will be triggered.

09c77b5330a3e916f7856788efe40649a152017cd57f83d91fa088850c7f5bce.png

SELL signal

  • Besides the ROI and stoploss, this strategy also has a sell signal configured and that sell signal is triggered when the RSI is above 80.

So now we know all of this, let’s backtest this strategy over all the timeperiods and let’s see if the 5 minute timeframe is indeed the most profitable one.

Initial backtest results

According to the backtest over all the available timeperiods I have the following results:

  • Best timeframe: 1 day
  • Total profit of strategy: -26%
  • Drawdown of strategy: 434 %
  • Winrate 96 %
  • Risk of ruin of strategy:  n/a %

9c1dc325f3e9a947b15cd2e4cecafe3d6d6392578b8a16d6e4c1747befdc3c0e.png

This is a strange result. We have a winrate of 96 percent and still the strategy is losing money. To see what is going on, we have to look at the backtest results and think about how this strategy is configured.

In these backtest results of the one day timeframe We can see that the strategy had 2390 wins to have 2088 USDT profit. But only 103 trades who stopped out with a total loss of 2357. And as you can see the average profit of a winning trade is only 1% but a losing trade has a 25% loss.  So to have a winning strategy with these numbers, you have to have 26 winners over one loser and this means that with these 103 losers I had to have at least 2678 winners.

7427c2fc3863351147352cf9d5e01d6753de1a620658180cac15cc821a2b6c68.png

Now that I know this, let's see if I can use Hyperparemeter optimization to improve this strategy.

For this I have changed the original code to add some optimisation spaces for the RSI indicator. I think that improving the buy and sell levels and maybe the timeframe of the RSI can improve the buy and sell signals. Also I will try to find the best ROI and stoploss settings for this strategy.

You can find this Hyperopt file below on this page.

Hyperparameter analysis

As expected I see some nice improvements after the hyperopt session. Profits improved to an end balance of 18301 usdt which is a profit of 1730 percent. The drawdown became 403 percent, which is not  a big improvement, but still an improvement. The winrate got a little lower but 72 % is still very admirable.

609942d243660ee04d7690d514080dce84b1aa18a44ad14e4903b67cbc388a9c.png

As you can see from the backtest results the improvements mainly come from the new ROI settings. Now the average profit is 21 percent. The stoploss percentage is also larger this time but the winrate and the winpercentage undo this loss. 

Also the ROI take profit points are quicker than the sell signal from the strategy because there is no sell signal registered which means that it is not triggered.

Ofcourse these results all depend on the hyperopt session and if you are optimizing the parameters of this strategy, you might come with even better or worse results. That’s because of the way parameter optimization works and I have discussed this in my video on hyperparameter optimisation earlier.

Let’s compare the profit charts and see how this strategy behaves over time…

Profit charts & conclusions

0cabe5f909017a7f11fc614a531d2753f00ed75442f8b2e8f3d6cdbb84e10668.png

The chart of the initial backtest shows some kind of sawtooth in the profit chart and the strategy does lose a lot of money when initial buy signals appear to be losing trades. 

Every time some profit is made after a lot of 1% winning trades, a couple of losing trades with 25% stop loss immediately lose all the gains and then some more. 

079174b0dd2722518288fa6c1f96eccc39dd15ed88e0da48c7c68eeea35ac26a.png

But if you look at the optimised chart you see again that profits are held quite good, even when there are bearish circumstances. Again in may 2021 you can see that there were some losing trades that took a good bite out of the gains. But then after a period of no trades the bot starts trading again with some profit. 

I always like to see a steady upward curve and under bearish conditions a horizontal line that indicates that there are no risky trades made.

Let’s see how this Simple strategy performs in comparison with the earlier tests I have done.

Strategy League

The Simple strategy enters the overall league in the 5th position. 

And it gets in front of the earlier tested ADX Momentum strategy of the same author.

9ffa2d0d7d1d45f7da1bb0c022ce2d5cd9a85d03e0934e3404838f8d3d712887.png

It has the highest winrate of all the tested strategies until now. And also the lowest amount of trades. But the profit is not very high in comparison to the better strategies. 

But with some additional tweaking this could be improved. 

But be careful that you don’t overfit to the curve because that can cause problems with future trades.

Also this strategy has trades with draws in the backtest so it has the potential to cause nonprofitable trades that cost trading fees.

Also the high stop loss percentage should be taken into consideration when you want to test this strategy further in your own backtest method.

The hyperopt code

# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame

# Add your lib to import here
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
import pandas_ta as pta
import numpy as np  # noqa
import pandas as pd  # noqa

# These libs are for hyperopt
from functools import reduce
from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter,IStrategy, IntParameter)
# --------------------------------
# freqtrade hyperopt --timeframe 1d --hyperopt-loss SharpeHyperOptLossDaily --space buy roi stoploss --epochs 10 -s SimpleHopt

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class SimpleHopt(IStrategy):
    """

    [email protected]: Gert Wohlgemuth

    idea:
        this strategy is based on the book, 'The Simple Strategy' and can be found in detail here:

        https://www.amazon.com/Simple-Strategy-Powerful-Trading-Futures-ebook/dp/B00E66QPCG/ref=sr_1_1?ie=UTF8&qid=1525202675&sr=8-1&keywords=the+simple+strategy
    """

    minimal_roi = {"0": 0.01}
    stoploss = -0.25
    timeframe = '5m'

    # The hyperopt spaces where the optimal parameters for this strategy are hidden
    rsi_buy_hline = IntParameter(50, 75, default=70, space="buy")
    rsi_sell_hline = IntParameter(70, 95, default=80, space="sell")
    rsi_period = IntParameter(4, 16, default=7, space="buy")

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        macd = ta.MACD(
            dataframe,
            fastperiod=12,
            fastmatype=0,
            slowperiod=26,
            slowmatype=0,
            signalperiod=9,
            signalmatype=0,)
        dataframe['macd'] = macd['macd']
        dataframe['macdsignal'] = macd['macdsignal']
        dataframe['macdhist'] = macd['macdhist']

        # For each value in the space of the indicator above, 
        # see if it produces better results in the buy/sell trend below
        for val in self.rsi_period.range:
            dataframe[f'rsi_{val}'] = ta.RSI(dataframe, timeperiod=val)

        bollinger = qtpylib.bollinger_bands(dataframe['close'], window=12, stds=2)
        dataframe['bb_lowerband'] = bollinger['lower']
        dataframe['bb_upperband'] = bollinger['upper']
        dataframe['bb_middleband'] = bollinger['mid']

        return dataframe

    def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (
                    # test the given indicator value in the buy condition
                        (dataframe['macd'] > 0)
                        & (dataframe['macd'] > dataframe['macdsignal'])
                        & (dataframe['bb_upperband'] > dataframe['bb_upperband'].shift(1))
                        & (dataframe[f'rsi_{self.rsi_period.value}'] > self.rsi_buy_hline.value)
                )
            ),
            'buy'] = 1
        return dataframe

    def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                # test the given indicator value in the sell condition
                (dataframe[f'rsi_{self.rsi_period.value}'] > self.rsi_sell_hline.value)
            ),
            'sell'] = 1
        return dataframe

The hyperopt json results

{
  "strategy_name": "SimpleHopt",
  "params": {
    "roi": {
      "0": 0.01
    },
    "stoploss": {
      "stoploss": -0.25
    },
    "trailing": {
      "trailing_stop": false,
      "trailing_stop_positive": null,
      "trailing_stop_positive_offset": 0.0,
      "trailing_only_offset_is_reached": false
    },
    "buy": {
      "rsi_buy_hline": 72,
      "rsi_period": 14
    },
    "sell": {
      "rsi_sell_hline": 79
    },
    "protection": {}
  },
  "ft_stratparam_v": 1,
  "export_time": "2022-02-05 16:44:54.403633+00:00"
}

How do you rate this article?


10

0

DutchCryptoDad
DutchCryptoDad

I'm just a regular Dutch dad with a passion for crypto, trading, technology and learning. This channel is my personal journey into the world of Crypto, blockchain, programming, trading bots, trading strategies, NFT's, Defi and many things more.


DutchCryptoDad
DutchCryptoDad

I'm just a regular Dutch dad with a passion for crypto, trading, technology and learning. This blog is my personal journey into the world of Crypto, blockchain, programming, trading bots, trading strategies, NFT's, Defi and many things more related to digital assets. I want to share my knowledge with others to help them as well in this vast world of digital assets.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.