Why TheForce Strategy Doesn't Work
TheForce gets amazing backtest results, but doesn’t work live.
The crazy backtest profits are only seen when using signalperiod=1
with ta.MACD(dataframe,12,26,1)
If we switch the MACD implementation from ta-lib, to qtpylib, most of the profits go away:
# MACD (Magic Profits)
macd = ta.MACD(dataframe,12,26,1)
dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']
# MACD (No Magic Profts)
macd = qtpylib.macd(dataframe['close'],12,26,1)
dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['signal']
dataframe['macdhist'] = macd['histogram']
================================================================ STRATEGY SUMMARY ===============================================================
| Strategy | Buys | Avg Profit % | Cum Profit % | Tot Profit USD | Tot Profit % | Avg Duration | Wins | Draws | Losses |
|-----------------+--------+----------------+----------------+------------------+----------------+----------------+--------+---------+----------|
| TheForceV7 | 1872 | 0.88 | 1641.61 | 24501.162 | 2450.12 | 0:56:00 | 1297 | 0 | 575 |
| TheForceV7_test | 1853 | 0.11 | 209.05 | 506.040 | 50.60 | 0:32:00 | 706 | 0 | 1147 |
=================================================================================================================================================
Why?
What seems to be happening is that ta-lib is, for some reason, cheating by looking into the future by 2 candles when signalperiod=1
.
This is an overlay of each implementation using signalperiod=2
, the results quickly converge and overlap each other.
This is an overlay of each implementation using signalperiod=1
, the ta-lib version is looking into the future by two candles. You can see that the ta-lib signal line is two candles “early”, predicting the future price movement.
Just double checking, here is each implementation using signalperiod=1
, but the ta-lib version has been shifted forward by two candles using .shift(2)
. The macd line is now two candles “late”, and the signal line once again lines up with the qtpylib implementation.
Sadly TheForce is looking into the future to predict the direction of price movement, which can’t happen during live or dry-run, unless you are an actual Jedi.