Covar (Function)
The Covar function calculates the covariance of two data series.
The covariance of two data sets measures their tendency to vary together. Where the variance is the average of the squared deviation of a data set from its mean, the covariance is the average of the products of the deviations of the data set values from their means.
Syntax
Covar(Indep,Dep,Length)
Returns (Double)
A numeric value for the current bar.
Parameters
Name | Type | Description |
Indep | Numeric | Specifies which independent bar value (price, function, or formula) to be considered when calculating the covariance. |
Dep | Numeric | Specifies which dependent bar value (price, function, or formula) to be considered when calculating the covariance. |
Length | Numeric | Sets the number of trailing bars to consider in the covariance. |
Remarks
The input parameters Indep and Dep can be a bar value such as Close, High, Low, Open, or Volume. They can also be any mathematical calculation such as High + Low) / 2, or a numeric function such as RSI, Stochastic, or ADX.
The value for the Length input parameter should always be a whole number greater than 0.
Example
Assigns to Value1 the covariance of 2 symbols; the Close of data1 to the Close of data 2 over the last 20 bars, then plots Value1.
Value1 = Covar(Close of Data1, Close of Data2, 20);
Plot1(Value1, "Covar");