Correlation Coefficient

Created by Karl Pearson, the Correlation Coefficient depicts the linear statistical correlation between two quote histories. R-Squared (R²), Variance, and Covariance are also output. [Discuss] 💬

chart for Correlation Coefficient

// usage
IEnumerable<CorrResult> results =
  quotesA.GetCorrelation(quotesB, lookbackPeriods);


quotesB IEnumerable<TQuote> - Historical quotes (B) must have at least the same matching date elements of quotesA.

lookbackPeriods int - Number of periods (N) in the lookback period. Must be greater than 0 to calculate; however we suggest a larger period for statistically appropriate sample size.

Historical quotes requirements

You must have at least N periods for both versions of quotes to cover the warmup periods. Mismatch histories will produce a InvalidQuotesException. Historical price quotes should have a consistent frequency (day, hour, minute, etc).

quotesA is an IEnumerable<TQuote> collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.




Date DateTime - Date from evaluated TQuote

VarianceA double - Variance of A

VarianceB double - Variance of B

Covariance double - Covariance of A+B

Correlation double - Correlation R

RSquared double - R-Squared (R²), aka Coefficient of Determination. Simple linear regression models is used (square of Correlation).


See Utilities and helpers for more information.


This indicator may be generated from any chain-enabled indicator or method.

// example
var results = quotes

🚩 Warning! Both quotesA and quotesB arguments must contain the same number of elements and be the results of a chainable indicator or .Use() method.

Results can be further processed on Correlation with additional chain-enabled indicators.

// example
var results = quotes