Home Creators Posts Import Register Favorites Logout
haven't archived this post yet. have a subscription? use the importer!

Downloads

  • nfix-files.7z

Missing 1 file, as this post has not yet been imported.

Content

This is a free repost of my test on the Nostalgia for infinity strategy with all the backtesting files that were build for the Freqtrade bot. Free because today is "Sinterklaas" in the Netherlands and I wanted to give everybody a 'present' for this special occasion.

Introduction

In this blog post I am going to install and test the much requested ‘Nostalgia for infinity’ strategy. This strategy is available on the https://github.com/iterativv/NostalgiaForInfinity github repository.  All credits of developing this code goes to its makers. This post is accompanied by the youtube video where I show how to test this NFIX strategy.

Downloading the code to your computer

To get the code, go to this github site. You will find three versions of the NFI strategy (at the time of writing this post).

In the description of the repository it says that the NFINext is an older strategy on the 5m timeframe , NFI-NG is a 15m tf strategy but is not under development and the current maintained version is the NostalgiaForInfinityX file.

Therefore I will use the NostalgiaforinfinityX maintained code for my test. You can see that this strategy is recently changed so indeed it is still actively maintained by the developers.

According to the developers of this strategy the general recommendations for use are:

  • Max 6 open trades.
  • A pairlist with 40 to 80 stable coin pairs is preferred, which I have with 50 pairs configured.
  • A volume pairlist. But volume pairlist only will work in real trading or forward testing so I keep this to my configured default static pairlist.
  • A blacklist for non trading pairs. I do not have a blacklist but the static pairlist is well configured to not have to use one.

Downloading the script is pretty easy when using wget. Just go to the github repository of the strategy and a little bit down below you will see the three python files with the code. In this case I am only going to use the NFIX code so just click on it, select the raw button and copy the URL.

To download this code directly to your computer, use the command below from within the strategies directory:

wget https://raw.githubusercontent.com/iterativv/NostalgiaForInfinity/main/NostalgiaForInfinityX.py

Explanation strategy

Now because I am not familiar with this strategy, I really would like to know how this strategy works.

However, at this time, the README file only contains information on how to install this file in your freqtrade bot and what the preferred configurations are.

The repository also contains a Wiki but reading through this wiki however also turns out to be a disappointment. Only the documentation on the setup, the specific configs, extra tips and other resources have been written. But the most interesting part for me is the page that tells me how this strategy works, which indicators it uses and how buy and sell signals are determined.

But unfortunately the developer of this code did not start to write this page yet.

Nonetheless the extra tips and other resources page did give me some other tips for future video subjects or just getting ideas for future projects. Like for example

  • Auto updater scripts
  • The use of Grafana for making dashboards
  • Conversion scripts to turn hyperopted strategies into regular strategies

Reading the code

Now I still want to know how this strategy works or just get an idea about it. So, I took the effort to look at the code the developers made. Then I realized why the developers did not yet start to write the strategy out in human readable form pseudocode in the wiki because this strategy consists of almost 11000 lines of code and is pretty complex to read.

Also, the number of comments that are available in the code are minimal. So trying to figure things out will be a tedious task to say the least.

Now you have to understand that I am not a professional Python programmer like the developers of this code. So, to see all these lines of code without any context or explanation is somewhat intimidating and a little bit out of my league.

However, I am going to try to explain the code from a high level perspective and stuff that I do understand or recognize. I will not go over it line by line because that would take hours but I will point out some interesting stuff.

Also be aware that I could be totally wrong on my interpretations of the code.

Top of the code

Let me start at the top of the code.

In this first section the necessary libraries are loaded into the strategy.

You can see in the picture below that the talib, qtpylib and pandas ta libraries will be loaded but also some additional indicators like RMI, ZEMA, VIDYA and Ichimoku from another technical library.

So, I suppose that a lot of indicators from different libraries will be used to determine strategies and buy/sell signals.

This next section gives us some comments on how to act on trades where you do not want to sell with a loss or only want to sell when reaching a certain amount of profit. For this you have to create some additional files in your freqtrade installation which should contain the trade ID’s or pairs.

However, you have to trade ID’s and you can only doscover these by watching the trade database for the current trade ID’s. I guess that will be a lot of manual work and that is not the principle of a trading bot in my opinion.

Generic strategy settings

This next section below contains the default settings each and every freqtrade strategy should contain. Like roi, stop loss, timeframe and more.

I can see here that the roi and stop loss will not be used in this strategy because they are set to 100 and -0.99. This way the sell signals will only come from the configured strategy settings.

Also there is no trailing stop loss.

The timeframe for this strategy is set to 5 minutes

And reading this strategy section, there will be additional informative timeframes added to the dataframe. I guess that this strategy will also look at higher time frames to determine if there should be buy or sell signals here.

Now informative BTC settings below also tell me that other pairs and higher time frames will be used to determine if there should be a buy or sell signal on the configured 5 minute timeframe.

And this following section below is also interesting

It looks like this strategy can rebuy the same pair but I’m not sure if these are consecutive rebuys or parallel rebuys..

Buy parameters

Now this whole dictionary of buy conditions looks like it has 65 combinations to make use of. This makes me think that these buy signals are flexible and very complex at the same time. But I can be wrong in my thinking of course…

Luckily for me there is only one sell condition here that I can enable or disable.

Individual buy conditions

Now this whole section with dictionaries has all the indicators that determine under which conditions a pair will be bought. It consists of around 26 indicator parameter settings which sometimes will also point to other methods below to figure out if a pair should be bought.

Hold trades

Below the 65 dictionaries, there are some configurations that load the freqtrade config file to determine which pairs are used. These pairs are then checked against the optional nfi-hold files you can create to hold certain pairs.

Now there will be a couple of methods that filter out the top traded coins and the coins that are top grossing.

All this coin information is copied to a coin_metrics dataframe.

Then these top coins will be used and added to a whitelist for further trading I think.

See this section below.

Stake amount per coin

Then here is another section that is quite interesting. Apparently this strategy can change the stake amount and position per coin configured. This will then be used for buy or rebuy of a coin.

Here this section checks how many entries a coin apparently has.

And next especially the section below gives me an indication that a pair can have multiple parallel trades open with a maximum of three. But each trade has another stake amount set by using a stake calculator.

Sell signals

The next part of the code contains the method that defines the sell signals.

There are 8 sell signals that are a combination of indicators and candle information.

What is interesting here is that these sell signals also have a sell reason. So, when we are going to backtest, its highly probable that we will see the sell reasons as well.

This way we can determine which reason is used the most for selling.

Stop loss methods

The next part of the code has the stop loss methods.

These will be triggered when a trade is in a loss and will close the position if all conditions are met.

Next there is another type of sell order section which only sells if the basic condition is that the candle close is above the EMA200 and then more indicator combinations to determine sell conditions.

And also when the close price is below the EMA200.

Also there is a method that sells after a pair has recovered and when it has a certain amount of profit.

Trailing stop loss

Then there is a method that acts as a trailing stop loss. See the sections below:

And more and more…

Sell after price pumps

Another section of this strategy handles selling orders after price pumps have been discovered.

Informative pairs

Then after a LONG list of sell reasons, there is a section that uses the informative pairs to determine if a pair should be bought. These informative pairs are on the 1d, 1h and 15m timeframes. So, it’s highly probable that these timeframes do not work when backtesting on multiple timeframes.

Normal timeframe indicators

Normal indicators and parameters are created after line 9280

Buy conditions

And from this point there are 65 types of buy condition combinations, each with their own name

Sell trend populations

And then sell trend populations which use the earlier created methods.

Strategy specific custom indicator section

And then at the very end of the file there is some code that provides us with custom indicators.

Apparently, these indicators are not available in the earlier imported indicator libraries but are determined in the strategy file here.

Let’s keep them in mind when future strategies will be developed that might use these indicators ;-).

(Simple) overview of the code

So, to recap this complete code in some very oversimplified steps and completely dependent on my own interpretation:

  • Pairs are selected on predefined circumstances like top traded or top grossing
  • Informative pairs on higher time frames are created to determine further if buy conditions are met. Including the indicators on their timeframes.
  • The indicators on the traded timeframe are created and
  • Then 65 different combinations of around 26 indicator parameters are used to determine if a pair will be bought
  • Then a whole bunch of sell methods are used that are based on profit, stop loss position of the current price and indicator combinations
  • Finally buy and sell parameters are set which use all the different earlier parameter  configurations and finally buy and sell pairs.

Now I really admire the person or persons who created this strategy. Not only because they clearly have put a lot of effort in creating all this code. But also they managed to create a pretty complex strategy and worked it out in code that actually seems to work.

Will this strategy be able to make profits during backtesting and how probable will it be that it will provide us with profits in real trading?

Analysis of the Backtest

Not only is the strategy script heavy on the coding and my understanding, it is also heavy on the processing power of my computer.

Unfortunately, but not unexpected, I only had backtest results from the 15 and 5 minute timeframe.

The most probable reason for not having any other timeframe backtest results is because these higher time frames are informative for making decisions on the lower time frames.

Another issue I got while backtesting is that I could not get any good backtest results on the 5 minute timeframe. As said, this strategy is very heavy on the computer’s resources, and I had to figure out what time range at least gave me some backtest results because the usual time range just erred out on me…

So, the complete dataset timed out and then I started to decrease this time range until I got some backtest results. Therefore, I only could backtest only over a year’s period on the 5-minute timeframe.

The last thing that I encountered was the report of these backtests. Under regular circumstances there are only 4 or 5 sell reasons at a max. and it is easy to understand why pairs are sold.

But because this strategy has so many sell combinations in its code, at some point I got 718 sell reasons in my report which also point to different sell tags.

Because there is no clear information on how to interpret these results, I had to make some semi-informed assumptions. Otherwise, I could not fill in my sheet to compare the different strategies.

Backtest results

Because of the problematic backtesting on the 5-minute time frame with its limited time range testing I am inclined to give more value to the 15-minute time frame results. And because these results are not bad at all, I will use these results in the overall strategy league. Here I am going on the save side.

Best timeframe: 15 minute

Total profit of strategy: 79 %

Drawdown of strategy: 757 %

Winrate 14 %

Risk of ruin of strategy: HIGH %

So let’s proceed to the Hyperparameter optimization section of these video’s because I have something to say about that as well…

Hyperparameter optimisation

Now because of the nature of this strategy with its over 700 reasons to sell, hyperparameter optimization is not really an option.

In addition to all these reasons I really do not think that optimizing ROI and stop loss are of much use  here. Even worse, it will probably break the strategy completely I think.

Hyper Optimization

Nonetheless I made an attempt to optimize this strategy by using the following command:

freqtrade hyperopt -c  user_data/backtest-config.json  --epochs 1000 --spaces stoploss roi --hyperopt-loss SharpeHyperOptLoss --timeframe 15 -s NostalgiaForInfinityX

But unfortunately this also proved to be very problematic and therefore I also had to skip the optimization of parameters. This should be no surprise though because ROI and stoploss were not used anyway in this strategy and I also could not find any indicators with optimizing configurations.

So let us just see at which spot this strategy will enter the strategy league…

Strategy league

The NFIX is a strategy with many rules and parameters that determine when a pair should be bought or sold. The code is very complex and only if you dig deep into it, you might be able to find out how it all works since the documentation is absent. I personally am not against a complex strategy because if it works, it works. But you should at least have to know how it works, even if it is complex, otherwise you cannot troubleshoot what’s wrong when it suddenly does not perform like expected or backtested.

Also the whole problem of not properly testing on the 5 minute timeframe over the complete dataset was disappointing, but since this strategy is heavy on memory and calculations because of all these rules I am not surprised.

So I decided to take the test results on the 15 minute timeframe and used them in my overall league.

And as you can see it entered on the second spot of this list.

What strikes me most is the high win rate and its low risk of ruin.

Also the drawdown is very reasonable.

But the strategy does not completely benefit from letting winners run and therefore has a somewhat disappointing end balance in comparison with the other top 5 strategies.

But nonetheless. If you cannot bear a possible streak of losing trades and a high drawdown, then this might be a strategy that you should investigate further and test on your own preferred coins and trading philosophy.

Comments

CryptoTee

What an excellent post! I appreciate your time and effort. 🙏🏽 May I make a suggestion. This strategy is not a 'normal' one. It seems to driving by hyper-updating of it. From my limited exposure the best alpha is gained by joining their discord server and then applying the different members' auto-update setting. It seems that this github and strategy is maintained on a daily (sometime several times/day) and this includes coin list curating and market fluctuation correction. It may be that f we treat this strat as a normal one we may be losing out on some alpha behavior that is supposed to be the recommended way to do things. Some things I like is the super active community and secondly the insistence that there is no money ever requested. Looks like the community and main devs have a passion to make it work. TL;DR : Apply their recommendations in their discord otherwise we may be just scratching the surface

Dutch Algotrading

Absolutely true. It is a very good community with a lot of enthousiastic honest, hard working people. Nonetheless I have a somewhat different view on algorithms that I do not quite 'understand' and is depending on external factors like auto update settings and such. You will never know for sure what makes it work and if something goes wrong, to whon do you go when the algo goes berserk, losing your account balance? Still this is a personal opinion and I want to be in control of the algorithms I use for trading. Or at least want to know what gives it its edge. To use an analogy here: you don't have know how a car exactly works, but at least must know how to drive one. To look at it from yet another point of view. In a way am also promoting their efforts so that more people may join their community and can contribute too. And hopefully I have succeeded in this

Risikovilje

I wonder if X4 would return better results. Currently running X4. What you live running atm?