Correlation

Top  Previous  Next

The Correlation function returns the statistical correlation for the specified number of bars between two markets.

 

Syntax

 

Correlation( series1, series2, barsToMeasure, [offset1], [offset2] )

 

Parameters

barsToMeasure

 

the number of bars over which to measure the correlation

series1

 

the first series

series2

 

the second series

offset1

 

the offset of the first series

offset2

 

the offset of the second series

 

 

 

returns

 

statistical correlation for last barsToMeasure bars

 

 

 

Example

soybeans.LoadSymbol( "S" )

gold.LoadSymbol( "GC" )

correlation = Correlation( soybeans.close, gold.close, 500 )

 

Returns the correlation between GC and S over the last 500 days

 

Returns a decimal number between -1 and 1. Returns -1 if the two series are perfectly negatively correlated. Returns 0 if the two series are not correlated at all. Returns 1 if the two series are perfectly positively correlated.

 

Generally less than .7 is considered uncorrelated, while .7 to .9 is considered loosely correlated and greater than .9 is considered closely correlated.