This function can be used to calculate the correlation coefficient (-1.0 to 1.0) of the stock being examined with a series. If a second series is specified, it calculates the correlation coefficient between them. If any of the series used have fewer than 80% of the number of samples requested, the function returns NA.
FYI: you can use ShowCorrel() in the screener to generate a report with a correlation matrix.
Parameters
period: number of bars used for calculating returns
samples: number of samples
series: the first series (see below)
series2: the second series (optional)
Examples
Calculate the correlation of the 1 day returns for the past three months of the stock vs. it's industry
Correl(1,62,#Industry)
Calculate the correlation of the 5 day returns for the past year of the stock vs. the ETF for the S&P500.
Correl(5,52,GetSeries("SPY"))
NOTES:
- See TIME SERIES IDS for the series ids.
- You can also use the GetSeries("ticker") functions
- Always use times series in the same country so that holidays line up.
Show more details