OPEN-SOURCE SCRIPT
Z-Score Multi-Model Clustering

A price/volume clustering framework combining three market behavior models into a single indicator. Designed to help identify emerging trend strength, turning points, and volatility-driven entries or exits.
🔍 How It Works
This indicator classifies market states by comparing normalized price/volume behavior (via Z-Score) to different types of statistical or geometric "cluster centers." You can choose from three clustering approaches:
🧠 Clustering Models
1. Percentile (Z+CVD) – Trend Momentum Bias
Uses volume Z-Score + Cumulative Volume Delta (CVD).
Detects institutional pressure by clustering volume surges with directional delta.
Best for: Breakouts, momentum trades, volume-led reversals.
Cluster Colors:
🔹 Green triangle = Strong bullish confluence
🔻 Red triangle = Bearish divergence (bull trap risk)
⚪ Gray = Neutral/low conviction
2. Euclidean (Z+Slope) – Swing Mean-Reversion
Measures the angle of recent Z-score slope and compares it to directional cluster centers.
Helps detect early directional shifts or exhaustion.
Best for: Swing entries, pullback setups, exit timing
3. Hilbert Phase – Turn Detection via Signal Phase
Applies Hilbert Transform to the Z-Score, measuring the phase difference between trend and oscillator components.
Ideal for anticipating turns or detecting cyclical inflection points.
Useful for: Scalping, top/bottom spotting, volatility fades
✅ Features
Auto-updating cluster logic based on current data
Tooltips and clean user interface
Optional cluster bar coloring (can be toggled off)
Signal-only plotting keeps candlesticks readable
Clear entry/exit logic with triangle markers
Supports trend, swing, and oscillation-based systems
🛠️ Suggested Use Cases
Combine with VWAP, Session High/Low, or Liquidity Zones to confirm entry conditions.
Use Cluster 2 (strong bullish) on pullbacks to trend structure for add-on entries.
Use Cluster 1 in strong trends to watch for potential traps or exits.
Toggle models based on your strategy: e.g., Hilbert for scalping, Percentile for macro trend breaks.
🧪 Best Timeframes
Works across all markets and timeframes
For Percentile (Z+CVD), use intraday TF with 1m–5m CVD source
Hilbert and Euclidean preferred on 5m–1h for accurate slope/phase signals
⚠️ Notes
Clusters do not generate trade signals alone; use them in context with structure, VWAP, or trend filters.
Marker signals are filtered with a magnitude threshold to reduce noise.
🔍 How It Works
This indicator classifies market states by comparing normalized price/volume behavior (via Z-Score) to different types of statistical or geometric "cluster centers." You can choose from three clustering approaches:
🧠 Clustering Models
1. Percentile (Z+CVD) – Trend Momentum Bias
Uses volume Z-Score + Cumulative Volume Delta (CVD).
Detects institutional pressure by clustering volume surges with directional delta.
Best for: Breakouts, momentum trades, volume-led reversals.
Cluster Colors:
🔹 Green triangle = Strong bullish confluence
🔻 Red triangle = Bearish divergence (bull trap risk)
⚪ Gray = Neutral/low conviction
2. Euclidean (Z+Slope) – Swing Mean-Reversion
Measures the angle of recent Z-score slope and compares it to directional cluster centers.
Helps detect early directional shifts or exhaustion.
Best for: Swing entries, pullback setups, exit timing
3. Hilbert Phase – Turn Detection via Signal Phase
Applies Hilbert Transform to the Z-Score, measuring the phase difference between trend and oscillator components.
Ideal for anticipating turns or detecting cyclical inflection points.
Useful for: Scalping, top/bottom spotting, volatility fades
✅ Features
Auto-updating cluster logic based on current data
Tooltips and clean user interface
Optional cluster bar coloring (can be toggled off)
Signal-only plotting keeps candlesticks readable
Clear entry/exit logic with triangle markers
Supports trend, swing, and oscillation-based systems
🛠️ Suggested Use Cases
Combine with VWAP, Session High/Low, or Liquidity Zones to confirm entry conditions.
Use Cluster 2 (strong bullish) on pullbacks to trend structure for add-on entries.
Use Cluster 1 in strong trends to watch for potential traps or exits.
Toggle models based on your strategy: e.g., Hilbert for scalping, Percentile for macro trend breaks.
🧪 Best Timeframes
Works across all markets and timeframes
For Percentile (Z+CVD), use intraday TF with 1m–5m CVD source
Hilbert and Euclidean preferred on 5m–1h for accurate slope/phase signals
⚠️ Notes
Clusters do not generate trade signals alone; use them in context with structure, VWAP, or trend filters.
Marker signals are filtered with a magnitude threshold to reduce noise.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。