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).
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?