OPEN-SOURCE SCRIPT

PSX OBV Divergence Labels (1H/4H/1D/1W, Enhanced)

316
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.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.