Myth-blowing : Hyperopt will turn any strategies to rocket strategies

Any new users will read about hyperopt and immediately think it can turn any strategies into a rocket strategies. This article is written to blow that myth to pieces.

In essence, hyperopt is just a series of backtesting runs. 500 epochs of hyperopt just means 500 different runs of backtest. Hyperopt isn’t some kind of Machine Learning. There are two important things that make hyperopt different than backtest

Hyperopt parameters

Main reason to use hyperopt is you can assign hyperopt parameter(s) in your strategy, and let the bot decides the best value(s) for each of them by running multiple backtests and changing the parameter(s) between each of those runs. The issue is how the bot decides which is the best. This is where most new users get it wrong. They assume the bot somehow can read the results and decides which certain epoch is the best.

Human can’t even have one same criteria of what is a “best” strategy. Which one is the best? Strategy A that has low number of trades and low total profit, but with high average profit, or Strategy B with high number of trades and higher total profit but low average profit? You can ask the same question to 100 users, and both strategies will at least chosen by one person.

That’s where the second thing comes into play, which is…

Hyperopt loss function

Based of the data from a backtest, the bot will calculate the total loss value of that specific backtest based of the function you assign. This loss function is important to let the bot know which epoch is the best. The loss value also used by the bot to determine the next values to be tested on next epoch. Freqtrade uses Bayesian search with a ML regressor algorithm (currently ExtraTreesRegressor) to quickly find a combination of parameters in the search hyperspace that minimizes the value of the loss function.

Loss function is so important as highlighted above, but yet users rarely put any time to learn and improve it. In my opinion, the loss functions that come with Freqtrade is a good starting point, but they are not good enough for my personal preferences. Please spend some time to read about loss function, and try out the different loss functions to see which indicators suit your preference, and create your own loss function.

Conclusion

Hyperopt isn’t a magic box where you just give it any strategy and it will make it better. It’s still a good tool to have, but to fully maximize its potential, you will need to spend time learning about it, especially the loss function.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *