How to use the correlation calculator
The calculator has two tools that work the same way. Two stocks is for shares, ETFs and indices. Two currency pairs lets you name the pairs so the labels and the explanation match your trade.
- Choose your data type. Pick Prices to paste closing prices, or Returns % if you already have period returns, for example from a spreadsheet or a portfolio report.
- Paste the two series, oldest first, for exactly the same dates. A column copied from a spreadsheet pastes directly. With prices, the calculator needs one more value than the number of returns: 31 closes give 30 returns.
- Choose the currency pairs on the forex tab. The pair names only change the labels; the maths is the same.
- Set the rolling window, the number of returns used for each point on the chart. Ten daily returns show short-term swings; 60 or more give a smoother line if you have the data.
The results show the correlation of returns with a plain-words interpretation, R², the number of observations, a 95% confidence range and the rolling range. In price mode you also see the correlation of raw price levels, for comparison.
How correlation is calculated
The calculator uses the Pearson correlation coefficient of returns:
ρ = Σ (at − ā)(bt − b̄) ÷ √[ Σ (at − ā)2 × Σ (bt − b̄)2 ]
R2 = ρ2Pt is the closing price in period t; at and bt are the returns of the two series and ā and b̄ their averages. ρ always lies between −1 and +1.
A value of +1 means the two returns always move in exact proportion in the same direction; −1 means they always move in exact proportion in opposite directions; 0 means no linear relationship. The confidence range uses the Fisher z-transformation, the standard method for a sample correlation:
A worked example
Two stocks. The example holds 31 daily closes for two companies in the same sector, which become 30 pairs of returns. Their correlation of returns is 0.60, a moderate positive relationship. R² is 35.7%: a little over a third of each stock’s daily variance lines up with the other’s.
With only 30 observations, the estimate is loose. The true correlation could plausibly be anywhere from 0.30 to 0.79.
Two currency pairs. The forex tab holds 31 daily closes of EUR/USD and GBP/USD. Their returns correlate at 0.71, a strong positive relationship, and the rolling 10-day correlation moved between 0.46 and 0.80 over the month.
Why you must correlate returns, not prices
Price levels are a running total of every past move, so any two series that drift the same way look related even if they have nothing in common: a spurious correlation. Returns strip out the trend and compare what actually happened each period.
| Data | Two unrelated stocks that both rose | The two example stocks |
|---|---|---|
| Correlation of price levels | 0.91 | 0.92 |
| Correlation of returns | -0.01 | 0.60 |
The first column comes from two simulated stocks whose daily moves were generated independently. Their prices correlate strongly because both climbed during the month, but their returns show essentially no link. That is why this calculator converts prices to returns before measuring anything.
How to read the result
- Sign. Positive means the two tend to rise and fall together; negative means one tends to rise when the other falls.
- Size. Rules of thumb treat 0.7 or more as strong and below 0.2 as negligible, but the thresholds vary. What matters more is how the number changes your decisions: two stocks correlated at 0.9 offer little diversification against each other, while a correlation near zero offers a lot.
- R². Squaring the correlation tells you how much of the movement is shared. A correlation of 0.5 sounds substantial, yet it means only a quarter of the variance is common.
- Sample size. Thirty observations give a wide confidence range. Two years of daily data, or five years of monthly data, give a far more reliable figure.
- Stability. The rolling chart shows whether the relationship held throughout the sample. Correlations between stocks often rise sharply in market sell-offs, exactly when diversification is needed most. A longer window smooths the line: with a 20-day window, the example’s rolling correlation ranges from 0.49 to 0.60.
Correlation in forex trading
Currency pairs share currencies, so many of them are linked by construction. Forex traders use correlation in three main ways.
Avoiding doubled risk. EUR/USD and GBP/USD have both been driven largely by the US dollar and have tended to move in the same direction. A long position in each is closer to one large dollar-short trade than to two independent ideas, so the combined risk is larger than either stop-loss suggests.
Spotting offsetting positions. EUR/USD and USD/CHF have the dollar on opposite sides, and have tended to move in opposite directions. Buying both mostly cancels out: you pay two spreads for a small net exposure. The forex hedging calculator uses this idea deliberately, sizing a position in a correlated pair to offset another.
Confirming or questioning a signal. When a pair breaks out but its usual partner does not follow, some traders read that as a warning.
Currency correlations are not fixed. Central bank decisions, risk sentiment and country-specific news can weaken or reverse a relationship for weeks at a time, so measure it on recent data with the same closing time for both pairs.
Limitations
- Linear only. Pearson correlation measures straight-line relationships. Two assets can be strongly linked in a crisis and unrelated the rest of the time, and the average hides it.
- Correlation is not causation. Two stocks may correlate because both respond to the same interest-rate news, not because one drives the other.
- Dates must match. Missing days, holidays in one market but not the other, or different closing times shift the returns and pull the correlation toward zero.
- No trading verdict. A historical correlation says nothing about whether a pairs trade or hedge built on it will be profitable after costs.
- Outliers matter. One extreme day can move the coefficient noticeably in a short sample. Check the rolling chart for sudden jumps.