## Intro

In this blog series I will be searching for the best trading strategy for cryptocurrency trading with a trading bot. These posts are complementary to the video's I make on Youtube, which you can watch below.

The trading bot I use is the Freqtrade (https://www.freqtrade.io/en/latest/) trading bot which not only has good options for bot trading, but also is excellent in backtesting and optimization of trading parameters. Therefore I will use this program to not only trade automatically, but also look for the best strategies and setups.

The strategy I investigate in this post is freely available in the Freqtrade github repository on the following location: https://github.com/freqtrade/freqtrade-strategies/tree/master/user_data/strategies/berlinguyinca

All credits go to the original author of this code.

## The backtesting setup

If you want to know more on how I do these backtests like: which pairs I use, which timeframes and which periods I test, then see this blog post to know more about the approach I use: https://www.publish0x.com/dutchcryptodad/is-it-profitable-or-not-the-setup-and-approach-xppgjoj

## Strategy

In this post I will show you the results of the backtests I did on the "Scalp strategy".

This strategy is part of a ‘trilogy’ of scalping strategies from the author that make use of the same indicators. Each variant of this strategy however is a slightly different and more advanced approach on how these indicators are used. This Scalp strategy is the simplest form.

This strategy was intended to work on the 1 minute timeframe!

The following indicators are configured and will be part of the dataframe to determine the buy and sell signals:

- The exponential moving average of the close price over the last 5 candles.
- Two other 5 day moving averages that will form a band around the closeprice EMA. One that uses the high price of the day and one ema that uses the low price of the day.
- The fast stochastics with settings of five, three and three.
- The ADX

The buy signal will be given when:

- The open price of the candle must be higher than the exponential moving average of the last 5 lowest candle prices.
- The fastk and fasted of the stochastics indicators should be over 30
- And the final signal for buying the asset is the actual crossover moment where the fast stochastics k line crosses over the d line.

The Sell signal is given when:

- The open price of the candle is equal or higher than the exponential moving average of the high of the last five candles.
- Or the fast stochastics FASTK should have a crossover above the 70 level or the fast stochastics FASTD would cross over the 70 level.

## Stoploss and takeprofit

This strategy makes use of the ROI and Stop loss functionality of the bot and uses the following rules:

- The ROI of this strategy is 1%. This means that the strategy will sell then the trade reaches 1% profit.
- The strategy has a stop loss of 4% so this tells me that the strategy should at least have a win rate of 4 to 1 to get break even.

## Initial backtest results

After backtesting, the initial backtest results are as follows:

- Best timeframe: 1 day
- Total profit of strategy: -35 %
- Drawdown of strategy: 488 %
- Winrate 49 %
- Risk of ruin of strategy: 146

The first thing that’s interesting is the high winrate of this strategy. The one hour timeframe even has a 72% winrate. However, this strategy loses money over all timeframes and I think that is because of the ratio between the ROI and the Stop loss settings. To be really profitable, the winrate should be 4 to 1 and that is not the case here.

Also the one minute time frame is not the timeframe where I would trade, but especially for this strategy I also included this in my test this time.

But as you can see from the results, it did not even keep break even and you would lose all our money in three months.

## Hyperparameter optimisation

For this strategy, hyperparameter optimization only were done on the ROI and Stop loss parts of the strategy with the following command:

freqtrade hyperopt -c user_data/backtest-config.json --epochs 1000 --spaces stoploss roi --hyperopt-loss SharpeHyperOptLossDaily --timeframe 1d -s Scalp

## Conclusions

Looking at these results I immediately notice the dramatic percentage wins over losses, and also the drawdown is very low.

The risk of ruin of this strategy is also very very low, compared with earlier backtests.

So this tells me that this strategy looks like it has a low risk setup.

However, because this strategy has a relative tight ROI setup, it really scalps the profits and then waits for another opportunity to trade.

And this is a little bit where I think the problem lies, because of this tight take profit the strategy also doesn't let its winners run and therefore the total profit of this strategy is also very low.

## Strategy League

REMARK: from this strategy now on I changed the weight of the winrate and the profit factors of a strategy. I added an additional weight factor to the amount of profit a strategy potentially could provide. This way the strategies that could potentially provide massive gains, while still having reasonably winning rates are rewarded more than those that are less or barely profitable but have super high win rates. So in short, I have rebalanced my risk appetite to have a higher risk in order for more profit.

Scalping on the daily timeframe with this strategy delivers you a profit while reducing risk.

But if your risk appetite is a little bit higher and you might want to gain more profits with your initial investment, then maybe this is not the correct strategy for you.

WIth the new weight factor added, this strategy comes in 5th in the strategy league.

## The strategy code

Note: this is NOT MY CODE !

## The hyperopt json results

```
}
"strategy_name": "Scalp",
"params": {
"trailing": {
"trailing_stop": false,
"trailing_stop_positive": null,
"trailing_stop_positive_offset": 0.0,
"trailing_only_offset_is_reached": false
},
"buy": {},
"sell": {},
"protection": {},
"roi": {
"0": 0.188,
"3090": 0.14100000000000001,
"14657": 0.063,
"44224": 0
},
"stoploss": {
"stoploss": -0.273
}
},
"ft_stratparam_v": 1,
"export_time": "2022-03-25 12:49:33.512638+00:00"
}
```