Skip to content
Algo Trade Analytics Docs

array.covariance() - Pine Script Function

The function returns the covariance of two arrays.

array.covariance(id1, id2, biased) → series float
NameTypeDescription
id1array<int/float>An array object.

The covariance of two arrays.

  • If biased is true, function will calculate using a biased estimate of the entire population, if false - unbiased estimate of a sample. Returns na if both arrays are empty.
//@version=6
indicator("array.covariance example")
a = array.new_float(0)b = array.new_float(0)
for i = 0 to 9
array.push(a, close[i]) array.push(b, open[i])
plot(array.covariance(a, b))