Built-in Correlation() function requires Range to be scalar (constant number).
Variable period correlation can be coded as follows:
// Variable period correlation
function VarCorrelation( x, y, number )
{
nom = MA( x * y, number ) - MA( x, number ) * MA( y, number );
denom = sqrt( MA( x ^ 2, number ) - MA( x, number ) ^ 2 ) *
sqrt( MA( y ^ 2, number ) - MA( y, number ) ^ 2 );
return nom / denom;
}
BTW: Use [code] ... your formula [/code]
tags !!! I fixed it again but why don’t you read How to use this site first?