OPEN-SOURCE SCRIPT
Enhanced Std Dev Oscillator (Z-Score)

Enhanced Std Dev Oscillator (Z-Score)
Overview
The Enhanced Std Dev Oscillator (ESDO) is a refined Z-Score indicator that normalizes price deviations from a moving mean using standard deviation, smoothed for clarity and equipped with divergence detection. This oscillator shines in identifying extreme overbought/oversold conditions and potential reversals, making it ideal for mean-reversion strategies in stocks, forex, or crypto. By highlighting when prices stray too far from the norm, it helps traders avoid chasing trends and focus on high-probability pullbacks.
Key Features
Customisable Mean & Deviation: Choose SMA or EMA for the mean (default: SMA, length 14); opt for Population or Sample standard deviation for precise statistical accuracy.
Smoothing for Clarity: Apply a simple moving average (default: 3) to the raw Z-Score, reducing noise without lagging signals excessively.
Zone Highlighting: Background colours flag extreme zones—red tint above +2 (overbought), green below -2 (oversold)—for quick visual scans.
Divergence Alerts: Automatically detects bullish (price lows lower, Z-Score higher) and bearish (price highs higher, Z-Score lower) divergences using pivot points (default length: 5), with labeled shapes for easy spotting.
Built-in Alerts: Notifications for Z-Score crossovers into OB/OS zones and divergence events to keep you informed without constant monitoring.
How It Works
Core Calculation: Computes the mean (SMA/EMA) over the specified length, then standard deviation (Population or adjusted Sample formula for N>1). Z-Score = (Source - Mean) / Std Dev, handling edge cases like zero deviation.
Smoothing: Averages the Z-Score with an SMA to create a cleaner plot oscillating around zero.
Levels & Zones: Plots horizontal lines at ±1 (orange dotted) and ±2 (red dashed) for reference; backgrounds activate in extreme zones.
Divergence Logic: Scans for pivot highs/lows in price and Z-Score; flags divergences when price extremes diverge from oscillator extremes (looking back 2 pivots for confirmation).
Visualisation: Blue line for the smoothed Z-Score; green/red labels for bull/bear divergences.
Usage Tips
Buy Signal: Z-Score crosses below -2 (oversold) or bullish divergence forms—pair with volume spike for confirmation.
Sell Signal: Z-Score crosses above +2 (overbought) or bearish divergence—watch for resistance alignment.
Customisation: Use EMA mean for trendier assets; enable Sample std dev for smaller datasets. Increase pivot length (7-10) in volatile markets to filter false signals.
Timeframes: Excels on daily/4H for swing trades; test smoothing on lower frames to avoid over-smoothing. Always combine with trend filters like a 200-period MA.
This open-source script is licensed under Mozilla Public License 2.0. Backtest thoroughly—past performance isn't indicative of future results. Trade with discipline! 📈
© HighlanderOne
Overview
The Enhanced Std Dev Oscillator (ESDO) is a refined Z-Score indicator that normalizes price deviations from a moving mean using standard deviation, smoothed for clarity and equipped with divergence detection. This oscillator shines in identifying extreme overbought/oversold conditions and potential reversals, making it ideal for mean-reversion strategies in stocks, forex, or crypto. By highlighting when prices stray too far from the norm, it helps traders avoid chasing trends and focus on high-probability pullbacks.
Key Features
Customisable Mean & Deviation: Choose SMA or EMA for the mean (default: SMA, length 14); opt for Population or Sample standard deviation for precise statistical accuracy.
Smoothing for Clarity: Apply a simple moving average (default: 3) to the raw Z-Score, reducing noise without lagging signals excessively.
Zone Highlighting: Background colours flag extreme zones—red tint above +2 (overbought), green below -2 (oversold)—for quick visual scans.
Divergence Alerts: Automatically detects bullish (price lows lower, Z-Score higher) and bearish (price highs higher, Z-Score lower) divergences using pivot points (default length: 5), with labeled shapes for easy spotting.
Built-in Alerts: Notifications for Z-Score crossovers into OB/OS zones and divergence events to keep you informed without constant monitoring.
How It Works
Core Calculation: Computes the mean (SMA/EMA) over the specified length, then standard deviation (Population or adjusted Sample formula for N>1). Z-Score = (Source - Mean) / Std Dev, handling edge cases like zero deviation.
Smoothing: Averages the Z-Score with an SMA to create a cleaner plot oscillating around zero.
Levels & Zones: Plots horizontal lines at ±1 (orange dotted) and ±2 (red dashed) for reference; backgrounds activate in extreme zones.
Divergence Logic: Scans for pivot highs/lows in price and Z-Score; flags divergences when price extremes diverge from oscillator extremes (looking back 2 pivots for confirmation).
Visualisation: Blue line for the smoothed Z-Score; green/red labels for bull/bear divergences.
Usage Tips
Buy Signal: Z-Score crosses below -2 (oversold) or bullish divergence forms—pair with volume spike for confirmation.
Sell Signal: Z-Score crosses above +2 (overbought) or bearish divergence—watch for resistance alignment.
Customisation: Use EMA mean for trendier assets; enable Sample std dev for smaller datasets. Increase pivot length (7-10) in volatile markets to filter false signals.
Timeframes: Excels on daily/4H for swing trades; test smoothing on lower frames to avoid over-smoothing. Always combine with trend filters like a 200-period MA.
This open-source script is licensed under Mozilla Public License 2.0. Backtest thoroughly—past performance isn't indicative of future results. Trade with discipline! 📈
© HighlanderOne
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。