Skip to content
All library documents

Using a Rolling Augmented Dickey–Fuller Test to Assess Mean Reversion

Article TradingView scripts

Summary

The document describes a TradingView indicator that applies the Augmented Dickey–Fuller test to a user-selected rolling window of price data. It fits a regression of price changes against the previous price, a constant, and optional lagged price changes, then plots the resulting test statistic alongside a critical threshold. Users can set the lookback length, maximum lag, and confidence level.

A statistic below the selected critical value is presented as evidence against a unit root and in favor of mean reversion in that sample. The indicator provides a visual signal and an optional information box; it does not define entries, exits, or a complete trading strategy. Its inference depends on the regression specification and window choice, and the document gives no empirical performance evidence. The result is a statistical test on a finite sample, not a guarantee that prices will revert or that a strategy using the signal will be profitable.

Key ideas

  • The indicator recalculates an ADF test over a moving window of price observations.
  • Optional lagged differences are included to account for serial correlation in price changes.
  • Users choose the sample length, maximum lag, and one of three confidence levels.
  • A test statistic below its critical value is interpreted as evidence favoring mean reversion in the sample.
  • The indicator supplies a diagnostic rather than trade rules or performance validation.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.