I would like to create standard deviation bands around another series. Does anyone know of a function to do that already available?
Announcement
Collapse
No announcement yet.
Does an efs exist to create a Std. Dev series from another series?
Collapse
X
-
PHP Code:// ------------------------------------
// Get a StdDev value
// Parameters:
// aSerie = Series Object
// nLength = Length of StdDev
// ------------------------------------
function getStdDev(aSerie, nLength) {
// get average
var vsma = sma(nLength,aSerie).getValue(0);
// Compute the numerator inside the square root
var sum = 0;
for (i=0; i<nLength; i++) {
sum += Math.pow((aSerie.getValue(-i)-vsma), 2);
}
var numerator = sum;
// Compute the denominator
var denominator = i - 1;
// Compute the value inside the square root
var value = numerator / denominator;
// Take the square root of the value to find the standard deviation
var stdev = Math.sqrt(value);
return stdev;
}
-
Comment