Skip to content
All library documents

Pairwise Return Regression for Cointegration Screening and Spread Signals

Article TradingView scripts

Summary

This TradingView indicator compares a user-selected set of assets using sampled weekly or monthly returns. For each pair, it fits a linear regression, measures the standard deviation of recent residuals, and displays the inverse deviation as a heatmap score. A separate table reports the latest residual spread, its recent mean, a Z-score, and a directional label when the score crosses the stated thresholds. The script also tries to align return observations across symbols and offers a period limit.

The method is a visual screening aid for candidate pairs and spread deviations. The document provides formulas and implementation details, but no empirical test of predictive power or trading performance. Its inverse residual deviation is only a proxy: it does not perform a formal cointegration or stationarity test, and the scale depends on the units and properties of the sampled returns. A low residual spread alone does not establish a stable relationship or guarantee mean reversion; the displayed trade labels should be independently validated.

Key ideas

  • The indicator fits a linear regression to each pair’s sampled returns and treats residuals as the spread.
  • It ranks pairs using the inverse of recent residual standard deviation.
  • A Z-score compares the latest residual with the recent spread distribution to label possible long or short setups.
  • The heatmap is a cointegration proxy, not a formal statistical test of cointegration or stationarity.

Tags

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