Skip to content
All library documents

Rolling Return Autocorrelation for Market Regime Detection

Article MQL5 code base

Summary

The document explains an oscillator that tracks one lagged-return autocorrelation estimate through time. At each bar, it calculates Pearson correlation between returns in a rolling window and the same returns shifted by a configurable lag. Positive readings indicate persistence associated with trending behavior; negative readings indicate reversal tendency. An EMA smooths the noisy raw estimate, while bands based on a Z-score divided by the square root of the window size provide a rough reference for sampling noise.

The author suggests using the smoothed line and bands to assess whether trend-following or range-oriented approaches may suit current conditions, and treating sustained zero-line crossings as possible regime changes rather than entry signals. Readings are based on returns, so they can be compared across differently scaled instruments. The document gives parameter defaults and qualitative guidance, but no empirical performance results. Its significance bands are an approximation, and the indicator does not predict direction or establish a standalone trading edge; the author recommends pairing it with directional or price-level analysis.

Key ideas

  • The indicator recalculates a fixed-lag return autocorrelation over a rolling window at each bar.
  • Positive autocorrelation suggests return persistence, while negative autocorrelation suggests reversal tendency.
  • EMA smoothing helps distinguish persistent behavior from noisy raw estimates.
  • Dynamic bands provide a rough threshold for judging whether readings may exceed sampling noise.
  • The oscillator describes return behavior, not direction, and is intended as a regime filter rather than a trade trigger.

Tags

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