We have decided to give EVERYTHING for free! What are you waiting for?



First of all, what is backtesting? It is the general method for seeing how well a strategy would have done in the past. Backtesting verifies the viability of a trading strategy by simulating how it would play out using historical data.

We’ll backtest the strategy example strategy we created using Bollinger Band and RSI using freqtrade https://cryptocue.io/bb-and-rsi-strategy-freqtrade/

After setting up the strategy, and placing it on user_data/strategies, we change our directory to the freqtrade main folder and proceed as follows:

$ freqtrade -c configfile backtesting –-strategy-list strategy1 –-ticker-interval=timeframe –-timerange=YEARMMDAY-YEARMMDAY

We’ll replace configfile by the name of our configuration file, strategy1 with the class name of the strategy, ticker interval with the supported timeframe that I want to test on the given exchange, in this case, we’ll be using 15m and we want to test on the timerange 20190601 to 20190701. We will test this strategy on the following USDT pairs: BTC, ETH, LTC, XMR and LINK (which are set on the configuration file) so it looks like this (add –refresh-pairs-cached if you need to download the trading data from binance)

$ freqtrade -c config.usdt.json backtesting –-strategy-list bbrsi –-ticker-interval=15m –-timerange=20190601-20190701 –refresh-pairs-cached

You only need to use –refresh-pairs-cached to refresh your historical database which is located on freqtrade/user_data/data/binance/

You can see the whole backtesting result at: https://pastebin.com/raw/8FuQ04r6

Interpreting the results

On the Backtesting Report section we can see: buy count, average profit %, cumulative profit %, total profit in BASE, total profit in %, average duration of the positions, amount of trades that were in profit and amounts of trades in loss.

We can see the best pairs were BTC/USDT and LINK/USDT but overall the strategy gives us a loss of -0.68% of the whole amount invested which can be see on the TOTAL row of Backtesting Report section.

The bot would still have a few open positions, which are detailed at the bottom on Left Open Trader Report.

Modify parameters and re-test

Let’s re-test this strategy on a bigger time frame, say 4 hour, we just need to run the same command as before but changing ticker-interval to 4hr

$ freqtrade -c config.usdt.json backtesting --strategy-list bbrsi --ticker-interval=4h --timerange=20190601-20190701 --refresh-pairs-cached

On this new ticker interval we get a 2.61% profit in just a single month, with a total of 12 buys, 7 stop_loss hit, 4 roi hits (meaning the position did reach our roi target, and 1 sell signal.

You can see the whole backtesting result here: https://pastebin.com/e4QdXWRi

Feel free to play around with more pairs, indicators, roi %, stoploss %, etc but try to avoid over fitting as it might give you unreliable results that might not repeat in the future. In our next post we’ll speak about common back testing mistakes from author Ernest Chan.

  • Nguyen
    4:16 PM, September 2020

    It’s really a good topic.
    it helps me a lot.
    Can you kindly share with us your config file, please. It will help me a lot since i’m still newbie with freqtrade.
    Thanks in advance,

    • CryptoCue
      6:18 PM, October 2020

      Hey. Freqtrade configuration file has changed a lot. I would recommend using the base and playing around with it. Join their slack.

Leave a Reply

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