CoefficientREasy (Function)

image\trumpet2.gif Disclaimer

The CoefficientREasy function calculates the Pearson product moment correlation coefficient, R using a single dependent variable and length.

The Pearson product coefficient, R, is a dimensionless index that ranges from -1.0 to 1.0 inclusive and reflects the extent of a linear relationship between Price and a dependent value for a specified period.

Pearson's product moment correlation coefficient, usually denoted by R, is one example of a correlation coefficient. It is a measure of the linear association between two variables that have been measured on interval or ratio scales.

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.

Syntax

CoefficientREasy(Dep,Length)

Returns (Double)

A numeric value between 1 and –1, for the current bar. If no value is calculated the function returns (-2).

Parameters

Name

Type

Description

Dep

Numeric

Specifies which dependent bar value (price, function, or formula) to be considered when calculating coefficient R.   

Length

Numeric

Sets the number of trailing bars to consider in the calculation of R.

Remarks

Under certain circumstances the function may not calculate a value for CoefficientREasy for the current bar. When this happens the function returns –2. You may want to check for this value and not plot for the current bar. Also, if you are looking for negative correlation you may want to add range checking. For example, if R < -.75 AND R > -1.01 then …

The value for the Length input parameter should always be a whole number greater than 0.

Example

Value1 = CoefficientREasy(Close,20);

If Value1>0.75 then

Plot1(High,"CoefRE");