OPEN-SOURCE SCRIPT
PSX OBV Divergence Labels (1H/4H/1D/1W, Enhanced)

This script identifies and labels bullish and bearish OBV divergences on the price chart, specifically optimized for swing trading in the Pakistan Stock Exchange (PSX) but also works well across global equities, indices, and crypto.
🔍 What It Does
📈 Bullish OBV Divergence (Green “BUY” label):
Price makes a new low while OBV forms a higher low — suggesting accumulation and a potential reversal.
📉 Bearish OBV Divergence (Red “SELL” label):
Price makes a new high while OBV forms a lower high — indicating distribution and potential weakness.
All signals are confirmed on candle close and filtered for smart volume and OBV stability, helping reduce noise and false positives.
⚙️ How It Works
OBV Divergence Lookback: Scans the last N bars (default 20) for divergence patterns
Volume Spike Filter: Bullish divergences are only considered valid if volume exceeds a smoothed average × multiplier
OBV Slope Confirmation: Confirms that OBV is moving in the expected direction across recent bars before signaling
Multi-Timeframe Support: Designed for 1H, 4H, 1D, and 1W timeframes — ideal for position and swing traders
📈 Best Use Cases
✅ PSX stocks (KSE100, KMI30)
✅ Crypto, indices, or commodities where volume data is available
✅ Works best when combined with price action, support/resistance, or market structure
📎 Parameters
OBV Divergence Lookback: Length of historical window to evaluate OBV vs. price divergence
Volume Smoothing: Period for volume moving average
Volume Spike Multiplier: Threshold for volume strength (default = 1.0x)
OBV Stability Confirmation Bars: OBV must show consistent direction across this many bars before confirming divergence
🧠 Pro Tip
Use divergence signals in confluence with:
Fair Value Gaps
Market Structure Breaks (BMS)
HTF Order Blocks or key SR levels
… for much stronger trade setups.
🔍 What It Does
📈 Bullish OBV Divergence (Green “BUY” label):
Price makes a new low while OBV forms a higher low — suggesting accumulation and a potential reversal.
📉 Bearish OBV Divergence (Red “SELL” label):
Price makes a new high while OBV forms a lower high — indicating distribution and potential weakness.
All signals are confirmed on candle close and filtered for smart volume and OBV stability, helping reduce noise and false positives.
⚙️ How It Works
OBV Divergence Lookback: Scans the last N bars (default 20) for divergence patterns
Volume Spike Filter: Bullish divergences are only considered valid if volume exceeds a smoothed average × multiplier
OBV Slope Confirmation: Confirms that OBV is moving in the expected direction across recent bars before signaling
Multi-Timeframe Support: Designed for 1H, 4H, 1D, and 1W timeframes — ideal for position and swing traders
📈 Best Use Cases
✅ PSX stocks (KSE100, KMI30)
✅ Crypto, indices, or commodities where volume data is available
✅ Works best when combined with price action, support/resistance, or market structure
📎 Parameters
OBV Divergence Lookback: Length of historical window to evaluate OBV vs. price divergence
Volume Smoothing: Period for volume moving average
Volume Spike Multiplier: Threshold for volume strength (default = 1.0x)
OBV Stability Confirmation Bars: OBV must show consistent direction across this many bars before confirming divergence
🧠 Pro Tip
Use divergence signals in confluence with:
Fair Value Gaps
Market Structure Breaks (BMS)
HTF Order Blocks or key SR levels
… for much stronger trade setups.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。