Autocorrelation
The Autocorrelation node measures the Pearson correlation between x[0..n−2] and x[1..n−1] within the rolling window — the lag-1 serial correlation. Output ranges from −1 to +1. Positive values indicate a trending, momentum-driven series; negative values indicate mean-reversion; values near zero indicate noise or randomness. Requires at least 3 non-null values.
Algorithm
- ▸Split window into lagged pairs: x = vals[0..n−2], y = vals[1..n−1]
- ▸Compute Pearson correlation: r = cov(x, y) / (std(x) × std(y))
- ▸Returns 0 when denominator is zero (flat series)
- ▸Requires ≥ 3 non-null values; otherwise null
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. Minimum 3. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Use Cases
Regime Classification
Autocorr > 0.3 → trending regime (favor momentum strategies); autocorr < −0.1 → mean-reverting (favor counter-trend entries).
Strategy Mode Switching
Gate trend-following entry signals with a high autocorrelation filter to avoid whipsaws in choppy regimes.
Indicator Quality
Apply Autocorrelation to an RSI or CCI series to measure whether it is moving directionally. High positive autocorrelation on RSI warns of oversold/overbought extremes persisting.