Mean Reversion Watchlist [Z score]

Hi Traders !

What is the Z score:

The Z score measures a values variability factor from the mean, this value is denoted by z and is interpreted as the number of standard deviations from the mean.

The Z score is often applied to the normal distribution to “standardize” the values; this makes comparison of normally distributed random variables with different units possible.

This popular reversal based indicator makes an assumption that the sample distribution (in this case the sample of price values) is normal, this allows for the interpretation that values with an extremely high or low percentile or “Z” value will likely be reversal zones.

This is because in the population data (the true distribution) which is known, anomaly values are very rare, therefore if price were to take a z score factor of 3 this would mean that price lies 3 standard deviations from the mean in the positive direction and is in the ≈99% percentile of all values. We would take this as a sign of a negative reversal as it is very unlikely to observe a consecutive equal to or more extreme than this percentile or Z value.

The z score normalization equation is given by

In Pine Script the Z score can be computed very easily using the below code.

// Z score custom function
Zscore(source, lookback) =>
    sma = ta.sma(source, lookback)
    stdev = ta.stdev(source, lookback, true)
    zscore = (source - sma) / stdev

The Indicator:

This indicator plots the Z score for up to 20 different assets (Note the maximum is 40 however the utility of 40 plots in one indicator is not much, there is a diminishing marginal return of the number of plots).

Z score threshold levels can also be specified, the interpretation is the same as stated above.

The timeframe can also be fixed, by toggling the “Time frame lock” user input under the “TIME FRAME LOCK” user input group (Note this indicator does not repaint).
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?