The main premise for detrending data is to remove the underlying trend effect on the strategy. This is due to the position bias that the strategy can have (eg being long more often than short).
Let’s say your strategy is long 70% of the time; and a bull market is currently taking place, there is a higher probability that you will be profitable. This could be due to the long position bias of your strategy – which might well become unprofitable during bear markets.
How to Detrend price data?
A simple way to detrend the data is to:
- Calculate the underlying trend in your backtest data
- Derive the “daily drift” from the underlying trend
- For each trade in the backtest, adjust the trade return by subtracting the daily drift for each day in the trade
For this it is easier to use log of price differences.
Step 1: The underlying trend is defined by the difference in price from the start to the end of the backtest:
Trend = LOG(Price_end / Price_start)
Step 2: Simply divide the underlying trend by the number of days in the backtest data:
Daily Trend Drift (DTD) = LOG(Price_end / Price_start) / NumDays
Step3: For each trade, apply the detrending adjustment calculated above:
LOG(TradeReturn) = LOG(SellPrice / BuyPrice) - DTD x NumDaysTrade
Note that the backtest is executed on normal, non-detrended data. It is the results that are adjusted by applying the detrending procedure.
Assuming a full reinvestment, the formula for the full detrended backtest result containing “n” trades would be as follows:
Detrending for Trend Following
It might sound paradoxal to remove the data component that is at the heart of the strategy (the trend)… On one hand, you realise it might make sense, as the underlying trend is at a much higher timeframe than the trends identified by the strategy. On the other hand, the detrending concept assumes a dissociation of the position bias and the underlying trend.
Is it true for Trend Following?
We could argue that if the underlying trend is bullish, bullish trends will be prominent at a lower timeframe (vice-versa for bearish trends). By the nature of Trend Following, we would therefore expect the strategy to spend more time in long positions (long position bias). Because Trend Following is exactly that: it adapts and goes in the direction of the trend.
In short: Trend Following automatically generates position bias in the direction of the trend
If these two variables (position bias and underlying trend) can not seem to be dissociated for Trend Following, it might not make sense to apply detrending for Trend Following.
The principle of applying a linear/proportional detrending adjustment assumes that the position bias is constant over time. It seems to ignore the potential for cyclical variations, possibly in line with major trend cycles (as would be expected with Trend Following).
For futures data, the detrending impact would be dependent on the method used for back-adjusted contracts. Point-based back-adjustment, for example, does not respect the proportional ratio between prices and would flaw the underlying trend calculation.
Finally, there are other factors that might need to be taken into account such as Contango and backwardation. The roll yield in futures trading, having possibly as strong an impact on the strategy’s return.
What are you thoughts on detrending for backtesting?…