Amjad_S

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
    zscore

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).
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?