OPEN-SOURCE SCRIPT

Z-Score Trend Monitor [EdgeTerminal]

226
The Z-Score Trend Monitor measures how far the short-term moving average deviates from the long-term moving average using the spread difference of the two — in standardized units. It’s designed to detect overextension, momentum exhaustion, and potential mean-reversion points by converting the spread between two moving averages into a normalized Z-score and tracking its change and direction over time.

The idea behind this is to catch the changes in the direction of a trend earlier than the usual and lagging moving average lines, allowing you to react faster.

The math behind the indicator itself is very simple. We take the simple moving average of the spread between a long term and short term moving average, and divide it by the difference between the spread and spread mean.

This results in a relatively accurate and early acting trend detector that can easily identify overbought and oversold levels in any timeframe. From our own testing, we recommend using this indicator as a trend confirmation tool.


How to Use It:

Keep an eye on the Z-Score or the blue line. When it goes over 2, it indicates an overbought or near top level, and when it goes below -2, it indicates an oversold or near bottom.

When Z-Score returns to zero or grey line, it suggests mean reversion is in progress.

You can also change the Z-Score criteria from 2 and -2 in the settings to any number you’d like for tighter or wider levels.

For scalping and fast trading setups, we recommend shorter SMAs, such as 5 and 20, and for longer trading setups such as swing trades, we recommend 20 and 100.

Settings:

Short SMA: Lookback period of short term simple moving average for the lower side of the SMA spread.

Short Term Weight: Additional weight or multiplier to suppress the short term SMA calculation. This is used to refine the SMA calculation for more granular and edge cases when needed, usually left at 1, meaning it will take the entire given value in the short SMA field.

Long SMA: Lookback period of long term simple moving average for the upper side of the SMA spread.

Long Term Weight: Additional weight or multiplier to suppress the long term SMA calculation. This is used to refine the long SMA calculation for more granular and edge cases when needed, usually left at 1, meaning it will take the entire given value in the long SMA field.

Z-Score Threshold: The threshold for upper (oversold) and lower (overbought) levels. This can also be set individually from the style page.

Z-Score Lookback Window: The lookback period to calculate spread mean and spread standard deviation

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.