CorrelationArray (Function)
The CorrelationArray function calculates the correlation coefficient for two named arrays.
Syntax
CorrelationArray(IndDepArray,DepArray,Size)
Returns (Double)
A numeric value between 1 and –1 for the current bar.
Parameters
| Name | Type | Description |
| IndDepArray | Numeric Array | Specifies the name of a numeric array of the independent values. |
| DepArray | Numeric Array | Specifies the name of a numeric array of the dependent values. |
| Size | Numeric | Sets the number of data elements (size) in the arrays to be evaluated. |
Remarks
A correlation coefficient is a number between -1 and 1, which measures the degree to which two variables are linearly related. If there is a perfect linear relationship with positive slope between the two variables, we have a correlation coefficient of 1; if there is a positive correlation, whenever one variable has a high (low) value, the other does also. If there is a perfect linear relationship with negative slope between the two variables, we have a correlation coefficient of -1; if there is a negative correlation, whenever one variable has a high (low) value, the other has a low (high) value. A correlation coefficient of 0 means that there is no linear relationship between the variables.
The value for the Size input parameter should be a whole number greater than 0. Also, Size cannot be larger than the number of elements in the smallest array.
The first element of the array that is used by this function is element 1. Element 0 of the array is not used.
Example
Assigns to Value1 the CorrelationArray value of one 10 element array to another 10 element array, then plots a ShowMe on the High when Value1 is greater than .75:
Array: myIndDepArray [10](0), myDepArray [10](0);
{… (assign values to both arrays) }
Value1 = CorrelationArray (myIndDepArray, myDepArray, 10);
if Value1 > .75 then
Plot1(High, "CorrA");