Docs

ta.zscore

Express how many standard deviations a value sits from its recent mean.

itm
ta.zscore(source, length, min=length)

Standard score: (source - sma(source, length)) / ta.stdev(source, length), using the population standard deviation (divisor length) as ta.stdev and ta.bb do.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber-1 to 10000Window in observed bars.
minConstantnumber-1 to 10000Valid values the window must hold before it reports (an option, written min=15). An na is skipped. Absent = length: the window must be full and gap-free.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until length consecutive non-na observations are in the window. An na resets the accumulation. na when the window has zero standard deviation. With min=, an na is skipped and the score is taken over the valid observations once there are at least min of them. A bar whose own value is na has no score.

Example

itm
ta.zscore(close, 20)
itm
plot(ta.zscore(close, 20), "Score 20")