Skip to content

Algorithm SDK

Math.standardDeviation

The standard deviation of a list of numbers: the square root of the variance. Cloud9Trader adds it to JavaScript’s built-in Math.

standardDeviation(x: number[]): number;
  • x: an array of numbers, such as the result of prices().

The population standard deviation, as Bollinger Bands use. The standardDeviation() indicator is a different thing: it works out the standard deviation of closes for you.

Stops the run if x is not an array: “Value passed to Math.standardDeviation() must be an array of numbers”.

function onIntervalClose() {
log("standardDeviation", Math.standardDeviation(prices(20)));
}