# Autocorrelation

Autocorrelation is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Plots the rolling autocorrelation of returns, squared or absolute returns, or detrended price at a chosen lag (lag 1 over a 200-observation window by default) with 2/sqrt(n) significance bands, a 20-lag ACF or PACF correlogram beside the last bar, and a regime dashboard. Alerts flag shifts into momentum, mean-reversion or back-to-noise conditions.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Jun 5, 2026.
- Access: free.
- Concepts: [Autocorrelation](https://www.luxalgo.com/library/concept/autocorrelation/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=u7m46u53us5foboyh8a7yhhm
- Page: https://www.luxalgo.com/library/indicator/autocorrelation/

**Autocorrelation** measures whether a market's moves persist, snap back, or carry no memory, with error bars attached. It keeps a rolling sample of the analyzed series, computes its [autocorrelation](https://www.luxalgo.com/library/concept/autocorrelation/) at the primary lag, and bands the reading at 2/sqrt(n), so a value only counts once it clears the noise floor. A correlogram beside the last bar draws one shaded column per lag (ACF, or PACF with shorter-lag influence stripped out), and the dashboard names the regime: Momentum, Mean Reversion, or Noise.

## How to Trade the Autocorrelation?

- **Above the upper band**: significant follow-through, momentum-friendly conditions, alerted on the crossing.
- **Below the lower band**: significant snap-back, mean-reversion-friendly conditions, likewise alerted.
- **Inside the bands**: persistence indistinguishable from noise, the honest default, alerted when a regime fades back inside.
- **Series picks the question**: Returns reads persistence of direction, Squared or Absolute Returns volatility clustering, Detrended Price cycles.

## Autocorrelation Settings

- **Source** (default close): price series feeding the analyzed series.
- **Series** (default Returns): also Squared Returns, Absolute Returns or Detrended Price.
- **Detrend Length** (default 20): moving average subtracted from price in Detrended Price mode; ignored otherwise.
- **Sample Window** (default 200): rolling sample size n. Longer tightens the bands but tracks regimes more slowly.
- **Primary Lag** (default 1): the lag plotted and monitored by the alerts; keep it well below the window.
- **Show Correlogram** (default on) with **Lags** (default 20) and **Mode** (default ACF): the per-lag profile.
- **Show Dashboard** (on) with **Location** (Top Right) and **Size** (Small); **Gradient Fill** (on).

## Frequently Asked Questions

### Autocorrelation or the Hurst Exponent for regime work?

The [Hurst Exponent](https://www.luxalgo.com/library/indicator/hurst-exponent/) condenses persistence into a single scaling estimate; autocorrelation resolves it lag by lag with a significance test at each. Hurst asks whether a market trends or reverts overall; the correlogram asks at which lag, and whether it beats luck.

### When should I use PACF instead of ACF?

When a long-lag reading might be short-lag correlation echoing through the chain: PACF strips out the shorter lags' influence so each column shows only that lag's direct effect. The pair is the classic combination for choosing model orders.

### Why does my reading sit inside the bands most of the time?

Because that is what liquid markets mostly look like: weak serial correlation is the norm, and the bands stop noise being traded as signal. Small Sample Windows widen the bands sharply, so only large effects register there.

## Related indicators

- [Arbitrage Detector](https://www.luxalgo.com/library/indicator/arbitrage-detector/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/arbitrage-detector.md
- [The Echo Forecast](https://www.luxalgo.com/library/indicator/the-echo-forecast/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/the-echo-forecast.md
- [Intermarket Swing Projection](https://www.luxalgo.com/library/indicator/intermarket-swing-projection/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/intermarket-swing-projection.md
- [Arbitrage Matrix](https://www.luxalgo.com/library/indicator/arbitrage-matrix/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/arbitrage-matrix.md
- [Correlated Sine Oscillator](https://www.luxalgo.com/library/indicator/correlated-sine-oscillator/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/correlated-sine-oscillator.md
- [Sector Correlation Matrix](https://www.luxalgo.com/library/indicator/sector-correlation-matrix/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/sector-correlation-matrix.md
- [Correlation Clusters](https://www.luxalgo.com/library/indicator/correlation-clusters/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/correlation-clusters.md
- [Historical Correlation](https://www.luxalgo.com/library/indicator/historical-correlation/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/historical-correlation.md

---

Source: https://www.luxalgo.com/library/indicator/autocorrelation/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
