OPEN-SOURCE SCRIPT

Z-Score

Updated
The z-score is a way of counting the number of standard deviations between a given data value and the mean of the data set.

Z-score = (x̄ - μ) / (σ / √ n)

x̄ = sample mean (using the array.avg function = array(a,close), where i = 1 to 21)
μ = population mean ( = avg(close, n))
σ = standard deviation of the population ( = stdev(close,n))
n = number of 'close' or trading day closes

n = input

... Note: The previous indicator is part of a larger series of indicators [statistical analysis of time series]
Release Notes
avg => sma
arraysmeanpopulationmeansamplemeanstatisticsVolatilityz-scorezscore

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer