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.
Obvdivergence
PSX OBV Divergence Labels (1D)PSX OBV Divergence Labels (1H/4H/1D/1W, Enhanced)
Description:
This indicator marks bullish and bearish OBV divergences on the price chart for PSX and other markets. Designed specifically for swing traders who operate on 1H, 4H, 1D, and 1W timeframes, it enhances basic divergence detection by incorporating volume spikes and OBV slope confirmation — improving signal reliability and reducing noise.
Key Features:
📈 Bullish Divergence: Marks potential buy zones when price hits a local low while OBV shows upward momentum with volume spike confirmation.
📉 Bearish Divergence: Flags potential sell zones when price hits a local high while OBV trends lower with volume weakness.
✅ Slope Confirmation: Filters signals based on sustained OBV direction over a user-defined number of bars.
🔊 Volume Filter: Detects divergence only when volume exceeds the average by a customizable multiplier (default 1.0).
🔍 Clean Visualization: Green “BUY” and red “SELL” labels show clearly on the chart, synced with candle price movement.
Best Timeframes to Use:
1H, 4H, 1D, and 1W (optimized for PSX stocks, KSE100, and KMI30)
Swing traders aiming for 2–4 week holding windows will find the most utility.
Recommended Settings:
OBV Lookback: 20
Volume Smoothing: 20
Spike Multiplier: 1.0
Slope Confirmation: 3 bars
Strategy Tip:
Use divergences in confluence with key support/resistance levels, price action traps, and market structure for high-probability setups. This tool is best used for trend exhaustion detection and reversal signals.
PSX OBV Divergence Labels (1D)PSX OBV Divergence Labels (1D)
This indicator highlights bullish and bearish OBV (On-Balance Volume) divergences on the price chart, specifically designed for daily timeframe swing trading in PSX (Pakistan Stock Exchange) stocks.
🟢 Green triangle (Bullish Divergence) appears when price makes a new low but OBV does not — suggesting accumulation and potential reversal.
🔴 Red triangle (Bearish Divergence) appears when price makes a new high but OBV does not — indicating weakening momentum and possible distribution.
Volume spike filtering is included to increase reliability. No trade signals or exits — this is a pure visual divergence tool to support manual decision-making. Ideal for spotting shifts in volume pressure ahead of price reversals.
Strength of Divergence Across Multiple IndicatorsOverview:
One-stop shop for all your divergence needs, including:
(1) A single metric for divergence strength across multiple indicators.
(2) Labels that make it easy to spot where the truly strong divergence is by showing the overall divergence strength value along with the number of divergent indicators. Hovering over the label shows a breakdown of each divergent indicator and its individual divergence strength value.
(3) Fully customizable, including inputs for pivot lengths, divergence types, and weights for every component of the divergence strength calculation. This allows you to quickly and easily optimize the output for any chart. Don't worry, the default settings will have you covered if you're not interested in what's going on under the hood.
The Divergence Strength Calculation:
The total divergence strength value is the sum of the divergence strengths of all indicators for which divergence was detected at a given bar. Each indicator's individual divergence strength is comprised of two basic components: (1) |ΔPrice| - the magnitude of the change in price over the divergence period (pivot-to-pivot), and (2) |ΔIndicator| - the magnitude of the change in indicator value over the divergence period.
Because different indicators' scales and volatility can vary greatly, the Δ values are expressed in terms of standard deviation to ensure that the values are meaningful and equitable across all indicators and assets/instruments/currency pairs, etc:
|ΔIndicator| = |indicator_value_1 - indicator_value_2| / 2 * StDev(indicator_series,100)
Calculation Weights:
All components of the calculation are weighted and can be modified on the Inputs page in settings (weights are simply multipliers). For example, if you think hidden divergence should carry less weight than regular divergence, you can assign it a lesser weight. Or if you think RSI divergence is worth more than OBV divergence, you can adjust their weights accordingly. List of weights:
Regular divergence weight - default = 1
Hidden divergence weight - default = 1
ΔPrice weight - default = 0.5 (multiplied by the ΔPrice component)
ΔIndicator weight - default = 1.5 (multiplied by the ΔIndicator component)
RSI weight - default = 1.1
OBV weight - default = 0.8
MACD weight - default = 0.9
STOCH weight - default = 0.9
Development for additional indicators is ongoing, as is research into the optimal weight configuration(s).
Other Inputs:
Pivot lengths - specify the number of bars before and after each pivot high/low to consider it a valid candidate for divergence.
Lookback bars and Lookback pivots - specify the number of bars or the number of pivots to look back across.
Price sources - specify separate price sources for bullish and bearish divergence
Display settings - specify how lines and labels should display, including which divergence strength values should show the largest labels. Include/exclude specific divergence types and indicators.
Please report any bugs, or let me know if you have any enhancement suggestions or requests for additional indicators.
@reees
BankNifty - OBVThis script tries to draw OBV for BankNifty using Futures Volume along with Average OBV. For Nifty50 just change the Futures Volume symbol in settings. Look at devations in Price vs OBV or Average OBV breakout.
NSE:NIFTY
NSE:BANKNIFTY
On Balance Volume Disparity IndicatorThe On Balance Volume Disparity Indicator was created by Phillip C. Holt (Stocks & Commodities V. 14:6 (265-269)). This converts the classic OBV indicator into Bollinger Bands and calculates the percentage of where the value lies within the Bollinger Bands. Buy when the obvdi rises above its signal line and sell when it falls below the signal line.
This was a special request so let me know what other indicators you would like me to write scripts for!
On Balance Volume ReflexThe On Balance Volume Reflex Indicator was developed by Fred Purifoy (Stocks & Commodities V 6:4 142-144) and it is similar in calculation to the On Balance Volume indicator but uses a lookback period for the change comparisons. Buy when the OVR is above the signal and sell when it falls below the signal.
I have included my On Balance Volume Modified Indicator to highlight the differences between both indicators.
Let me know if you would like to see me write scripts for more indicators!
On Balance Volume ModifiedHere is a smoothed version of the classic OBV indicator with a signal line. You can use it to look for signal line crossovers and divergences. The signal line is a 10-day EMA of the OBVM line. Typically, the signal line can vary from 10 to 50.
This was just published by Vitali Apirine in the latest issue of Stocks & Commodities (April 2020) p22-25
Please let me know if you want me to publish any other indicators or if you have any questions!