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 resultsWhoops, this section is for members only. If you have a membership, please log in. If not, you can definitely get access by buying one of our plans! Purchase the essential plan or Purchase the Professional Plan .
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.