# Historical Correlation

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

Measures how up to 10 ticker pairs have correlated from any anchor point you set, drawn as evolving line plots or as a heatmap of the latest readings. Optional anchor periods restart the calculation every hour, day, week, month, quarter, or year. Backbone statistics for pair traders, hedgers, and anyone balancing a portfolio.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Mar 14, 2024.
- Access: free.
- Concepts: [Correlation](https://www.luxalgo.com/library/concept/correlation/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn201x002qvhsgr4le1ho1
- Page: https://www.luxalgo.com/library/indicator/historical-correlation/

**Historical Correlation** tracks the [correlation](https://www.luxalgo.com/library/concept/correlation/) coefficient (the −1 to +1 measure of how faithfully two assets move in step) for up to 10 user-defined ticker pairs, starting from an anchor point you confirm by clicking a bar or picking a date in the settings. Two displays cover the two questions traders ask: LINES mode plots each pair's coefficient evolving through time, while HEATMAP mode renders the most recent values as a color-graded snapshot.

## How to Trade the Historical Correlation?

- **Readings near +1**: the pair moves in sync. Divergences between two tightly correlated assets are the raw material of pair trading.
- **Readings near −1**: the pair moves inversely, which is what a hedge is made of: long one, and the other tends to offset it.
- **Readings near 0**: independent movement, the property diversification depends on, and a warning when two supposedly different holdings sit near +1 instead.

Sector rotation work benefits from the same data, since watching how sector and market-wide correlations shift can reveal which groups are decoupling. The anchored design matters here: relationships drift, and the tool shows exactly how they have evolved since the point in time you care about.

## Historical Correlation Settings

- **Anchor Point**: the bar the calculation starts from.
- **Anchor Period**: NONE, HOURLY, DAILY, WEEKLY, MONTHLY, QUARTERLY, or YEARLY. With NONE the calculation never resets; any other choice restarts it at each new period's first bar.
- **Ticker Pairs (1-10)**: choose each pair, toggle its visibility, and color-code it.
- **Drawing Mode**: LINES for historical plots, HEATMAP for the current snapshot.

## Frequently Asked Questions

### Why do the correlation values restart partway through the chart?

That is the Anchor Period at work. With MONTHLY selected, for example, coefficients recalculate from the first bar of each month, so every month is judged on its own relationships rather than inheriting stale data.

### How many assets can I compare at once?

Up to 10 pairs simultaneously, each independently toggled and colored. If you would rather see how a whole basket organizes itself into groups, [Correlation Clusters](https://www.luxalgo.com/library/indicator/correlation-clusters/) approaches the same statistic from that angle.

### Do I need a subscription to use it?

No. Historical Correlation is one of the free tools on the LuxAlgo Library, available directly from this page. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Correlation Clusters](https://www.luxalgo.com/library/indicator/correlation-clusters/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/correlation-clusters.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
- [Arbitrage Detector](https://www.luxalgo.com/library/indicator/arbitrage-detector/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/arbitrage-detector.md
- [Arbitrage Matrix](https://www.luxalgo.com/library/indicator/arbitrage-matrix/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/arbitrage-matrix.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
- [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
- [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
- [Correlation Coefficient](https://www.luxalgo.com/library/indicator/correlation-coefficient/) (Correlation): markdown at https://www.luxalgo.com/library/indicator/correlation-coefficient.md

---

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