Autocorrelation Node
Measures self-correlation at different time lags
Overview
Autocorrelation measures how strongly a time series correlates with itself at different time lags. It identifies whether past values have a statistically significant relationship with current values, revealing patterns that repeat at regular intervals (seasonality, cycles, mean reversion).
Understanding autocorrelation is crucial for time series analysis because standard statistical tests often assume independence between observations. High autocorrelation violates this assumption and affects the reliability of statistical models. It also helps identify whether price movements show momentum (positive autocorrelation) or mean reversion (negative autocorrelation).
Formula & Calculation
ACF(5) = 0.15 means today's return has weak correlation with 5 days ago
ACF(20) = -0.20 means 20-period lag shows slight negative autocorrelation (mean reversion)
💡 Lag Selection: Typical lags range from 1-50 periods. Plot ACF values across lags to visualize the correlation structure. Lags beyond the 95% confidence bands are statistically significant.
Parameters
| Parameter | Default | Description |
|---|---|---|
| lag | 1-20 | Number of periods to calculate correlation. Higher lags show longer-term relationships. |
| source | Close | Input data series (typically closing prices or returns) |
| lookback | 100 | Number of periods to use for calculating autocorrelation |
Common Use Cases
1. Detect Seasonality & Cycles
Spikes in ACF at specific lags reveal seasonal patterns. For example, if ACF is high at lag-252 (1 year), the market shows seasonal behavior recurring yearly. Lag-5 spikes indicate weekly cycles. Use this to adjust strategies for predictable seasonal patterns.
2. Identify Momentum vs Mean Reversion
Positive ACF indicates momentum (trending behavior) - recent price action predicts future changes. Negative ACF indicates mean reversion - price tends to reverse after moving. ACF near 0 suggests random walk. This determines which trading strategy to use.
3. Test Stationarity & Mean Reversion
ACF that decays slowly suggests non-stationary data (needs differencing). Rapid decay indicates stationary data suitable for many statistical models. Used to validate whether pairs trading (cointegration) will work correctly.
4. Validate Trading Models
Check if residuals from a trading model have significant autocorrelation. If they do, your model is missing important information hidden in the autocorrelation structure. Use to improve model design and incorporate discovered patterns.
Advantages & Limitations
Advantages
- •Reveals hidden patterns and cycles
- •Identifies momentum vs mean reversion
- •No parameters to optimize
- •Mathematically rigorous foundation
- •Useful for validating models
Limitations
- •Only works with stationary data
- •Doesn't show causal relationships
- •Requires sufficient historical data
- •Complex interpretation for traders
- •Changes over time (non-stationary)
Tips & Best Practices
📊 Plot ACF Diagrams
Visualize ACF values with confidence bands. Values outside the bands are statistically significant. Look for patterns: sharp drop-off (stationary), slow decay (trending), spikes at regular intervals (seasonal).
🔄 Use ACF on Returns Not Prices
Price autocorrelation is usually high due to trends. Calculate returns (price changes) first, then ACF on returns. This reveals the true autocorrelation structure that trading strategies can exploit.
⚡ Combine with PACF
Partial ACF (PACF) removes effects of intermediate lags, isolating direct relationships. ACF + PACF together determine the best ARIMA parameters for forecasting models.
⚠️ Check for Non-Stationarity
If ACF decays very slowly (stays high for many lags), the data likely isn't stationary. Difference the data (subtract previous value) and recalculate. Most statistical tests require stationary data.
Example Strategy: Autocorrelation-Based Trading
Setup
- • Calculate ACF for lags 1-20 using daily returns
- • Monitor ACF(1) and ACF(5) for changes
- • Identify periods of positive vs negative autocorrelation
Momentum Strategy (Positive ACF)
If ACF(1) > 0.30: Use momentum (trend-following) strategies. Price has momentum - recent changes predict future changes. Use moving average crossovers or breakout systems.
Mean Reversion Strategy (Negative ACF)
If ACF(1) < -0.20: Use mean reversion strategies. Price tends to reverse - recent moves are likely followed by opposite moves. Use RSI divergences, Bollinger Band reversals.
💡 Dynamic Strategy Selection: Calculate ACF monthly and switch strategies based on autocorrelation structure. This adaptive approach often outperforms fixed strategies.