Login Page - Create Account

Technical Studies Reference


Correlation Coefficient

The study calculates and displays the Correlation Coefficient between the variables specified by the Input Arrays 1 and 2 Inputs. These Input arrays can refer to any Subgraph of the Main Price Graph or any study on the chart.

Let \(X^{(1)}\) and \(X^{(2)}\) be random variables denoting Input Array 1 and Input Array 2, respectively, and let \(X^{(1)}_i\) and \(X^{(2)}_i\) be their respective values at Index \(i\). Let the Input Length be denoted as \(n\). Then we denote the Correlation Coefficient at Index \(t\) as \(\rho_t\left(X^{(1)},X^{(2)},n\right)\) (Greek letter rho), and we compute it in terms of Simple Moving Averages for \(t \geq n\) as follows.

\(\displaystyle{\rho_t\left(X^{(1)},X^{(2)},n\right) = \frac{\sum_{i = t - n + 1}^t\left(X^{(1)}_i - SMA_t\left(X^{(1)},n\right)\right)\left(X^{(2)}_i - SMA_t\left(X^{(2)},n\right)\right)}{\sqrt{\sum_{i = t - n + 1}^t\left(X^{(1)}_i - SMA_t\left(X^{(1)},n\right)\right)^2}\sqrt{\sum_{i = t - n + 1}^t\left(X^{(2)}_i - SMA_t\left(X^{(2)},n\right)\right)^2}}}\)

For an explanation of the Sigma (\(\Sigma\)) notation for summation, refer to our description here.

The above formula describes how the Correlation Coefficient is calculated by Sierra Chart, but it is cumbersome to test this formula in spreadsheet form. Therefore, the following mathematically equivalent formula was used in the spreadsheet test.

\(\displaystyle{\rho_t\left(X^{(1)},X^{(2)},n\right) = \frac{n\sum_{i = t - n + 1}^t X^{(1)}_iX^{(2)}_i - \left(\sum_{i = t - n + 1}^t X^{(1)}_i\right) \left(\sum_{i = t - n + 1}^t X^{(2)}_i\right)}{\sqrt{n\sum_{i = t - n + 1}^t \left(X^{(1)}_i\right)^2 - \left(\sum_{i = t - n + 1}^t X^{(1)}_i\right)^2}\sqrt{n\sum_{i = t - n + 1}^t \left(X^{(2)}_i\right)^2 - \left(\sum_{i = t - n + 1}^t X^{(2)}_i\right)^2}}}\)

Inputs

  • Input Array 1: This Input is used to select the first Input array to use in the Correlation Coefficient calculation. There are two list boxes displayed. The first one is for selecting the main price graph or a study on the chart. The second one selects a specific Subgraph within that selected main price graph or study, to use the data from.

    It is possible to reference the main price graph or study data from another chart. Open the other chart you want to reference. Add the Study/Price Overlay study to the chart containing the Correlation Coefficient study. Configure the Study/Price Overlay study as you require. Once the Study/Price Overlay study is on the chart, you will then be able to set Input Array 1 to this study that is referencing data from another chart.
  • Input Array 2: This Input is used to select the second Input array to use in the Correlation Coefficient calculation. There are two list boxes displayed. The first one is for selecting the main price graph or a study on the chart. The second one selects a specific Subgraph within that selected main price graph or study, to use the data from.

    It is possible to reference the main price graph or study data from another chart. Open the other chart you want to reference. Add the Study/Price Overlay study to the chart containing the Correlation Coefficient study. Configure the Study/Price Overlay study as you require. Once the Study/Price Overlay study is on the chart, you will then be able to set Input Array 2 to this study that is referencing data from another chart.
  • Length

Spreadsheet

The spreadsheet below contains the formulas for this study in Spreadsheet format. Save this Spreadsheet to the Data Files Folder.

Open it through File >> Open Spreadsheet.

Correlation_Coefficient.218.scss


*Last modified Monday, 26th September, 2022.