If I am testing a trend-following strategy, should I detrend the data before applying the rules or should I generate signals based on the original price series but use detrended data for performance evaluation ? If I use a trend-following strategy with detrended data, it may not generate signals as it would with real price series.


2 Answers 2


Depends on what the goal is. If you want to backtest a priced based signal (e.g. RSI, SMA Crossovers, Bollinger Bands or other technical indicators) then it wouldn’t make much sense to detrend the time series just for the sake of it. The backtest doesn’t really care about the nature of the signal as long as you don’t use information unavailable at the time of financial decision making (i.e. future data).

Detrending becomes important for statistical analysis and inference. For example if you want to answer something like “how well does signal $x_t$ predict returns of series $y$ at $t+1$”. You will be led to a wrong conclusion if you don’t account for the fact that the price series is highly autocorrelated.

  • 1
    $\begingroup$ Detrending and taking first differences are two distinct transformations, yet you seem to be referring to them synonymmically. $\endgroup$ Commented May 5, 2023 at 11:20
  • $\begingroup$ @RichardHardy You’re right, I used them interchangeably by mistake! I don’t think it changes the core of the argument though. Would you agree? $\endgroup$
    – oronimbus
    Commented May 6, 2023 at 6:26
  • 1
    $\begingroup$ The core is fine, but I would fix the mistake by editing the answer accordingly. $\endgroup$ Commented May 6, 2023 at 7:40

I am not sure why you want to use detrending as part of a backtest. The only book I know that advocates such an approach is D. Aronson's Evidence based technical analysis, Wiley, 2006.

The valid point he makes is that if you test a stock market timing strategy that goes into and out of the market at random times, it will make money over a long period simply because the stock market rises over the long run. But that does not make it an attractive strategy.

He advocates fitting a trend line to the S&P 500 prices over the backtest period (by connecting the starting and ending prices) and simulating buys and sells at an adjusted price equal to the actual price minus the trend line. For signal generation you would use the real prices. If you buy and sell at random using these adjusted prices you will make a P&L of zero, correctly showing the strategy is worthless. Some people call these prices the "drift ajusted prices" (it is a term I like more than 'detrended' which has many meanings).

The approach I prefer is to backtest 2 strategies using the same software and (unadjusted) data, the strategy you are interested and a Buy and Hold strategy that is fully invested in the S&P 500 at all times. Then you compare the stats for the 2 strategies and try to see if your strategy has an advantage over BH either in terms of excess returns or lower volatility, lower drawdown, etc. I think it is easier and cleaner to compare two realistic strategies rather than looking at a strategy that trades at made up prices. But that is just my opinion.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.