OPEN-SOURCE SCRIPT

On Balance Volume [BrightSideTrading]

82
imagen
# On Balance Volume [Enhanced Signals] - Complete User Guide

## Overview

This enhanced OBV indicator provides clean, actionable volume analysis with intelligent signal filtering. It combines On-Balance Volume (OBV) with a smoothed signal line to identify shifts in buying and selling pressure without chart clutter.

**Key Features:**
- Real-time OBV and signal line visualization
- Smart crossover detection with confirmation filtering
- Z-Score momentum analysis
- Customizable signal alerts with V-shaped markers
- Window-normalized option for detrended analysis

---

## What is On-Balance Volume (OBV)?

OBV is a volume-based momentum indicator that accumulates volume on up days and subtracts volume on down days. It answers a fundamental question: **Is volume flowing in (buying) or out (selling)?**

**Formula:**
- If Close > Previous Close: OBV = Previous OBV + Volume
- If Close < Previous Close: OBV = Previous OBV - Volume
- If Close = Previous Close: OBV = Previous OBV (unchanged)

**What it tells you:**
- **Rising OBV** = Accumulation (smart money buying)
- **Falling OBV** = Distribution (smart money selling)
- **OBV above zero line** = Net positive buying pressure
- **OBV below zero line** = Net negative selling pressure

---

## Interface & Settings

### **MAIN VISUALIZATION**

**OBV Line (Green/Red Ribbon)**
- Green when OBV is above the signal line (bullish trend)
- Red when OBV is below the signal line (bearish trend)
- Toggles between window-normalized (detrended) and raw values

**Signal Line (Orange)**
- Smoothed average of OBV
- Crossovers with OBV generate buy/sell signals
- Default: 21-period SMA

**V-Shaped Markers**
- Green upward V = Bullish crossover (buy signal)
- Red downward V = Bearish crossover (sell signal)
- Appears at the OBV value when signal is triggered

**Zero Line (Yellow)**
- Center equilibrium point for volume balance
- Acts as support/resistance for OBV
- Separates buying pressure (above) from selling pressure (below)

---

### **SOURCE GROUP**

**Source**
- **Default:** Close
- **Options:** Open, High, Low, or any custom value
- Controls which price value triggers OBV direction changes
- Most traders use Close for standard OBV calculation

---

### **SIGNAL SMOOTHING GROUP**

**Show Signal?**
- **Default:** ON
- Toggle visibility of the signal line
- Disable if you prefer to see raw OBV only

**Smoothing Type**
- **SMA (Simple Moving Average)** - Default, standard smoothing
- **EMA (Exponential Moving Average)** - Faster response, weights recent bars more heavily
- **Choose SMA** for consistent, traditional OBV signals
- **Choose EMA** for faster trend identification (more whipsaws possible)

**Smoothing Length**
- **Default:** 21 bars
- **Range:** 1-200 bars
- **Lower values** (5-14): Faster signals, more noise
- **Higher values** (30-50): Slower signals, fewer false alarms
- **Recommendation:** Use 21-25 for most timeframes

---

### **SIGNAL FILTERING GROUP**

This is your primary control for signal quality and frequency.

**Show Signal Markers?**
- **Default:** ON
- Toggle the V-shaped buy/sell markers on/off
- Disable if markers distract from your analysis

**Signal Filter Type**
- **None** - Shows every single crossover (noisy, best for skilled traders)
- **Confirmation Bars** - Waits N bars before confirming signal (recommended)
- **Strength-Based** - Only signals during strong momentum (filters weakest moves)

#### **CONFIRMATION BARS MODE** (Recommended)
Best for reducing false signals while staying responsive to real moves.

**Confirmation Bars**
- **Default:** 2 bars
- **Range:** 1-10 bars
- Waits for the signal to hold for N consecutive bars after crossover
- **Setting 1:** Every crossover (same as "None")
- **Setting 2:** Wait 1 bar confirmation (good balance)
- **Setting 3:** Wait 2 bars confirmation (filters 50% of noise)
- **Setting 4+:** Very selective, misses quick reversals

**How it works:**
1. OBV crosses signal line → Confirmation counter starts
2. If OBV stays on correct side for 2 bars → V-marker appears
3. If OBV crosses back → Counter resets, no signal

#### **STRENGTH-BASED MODE**
Only signals when momentum is statistically significant.

**Min Z-Score Strength**
- **Default:** 0.3
- **Range:** 0.0-3.0
- Requires OBV deviation from its mean to reach this threshold
- **Setting 0.1-0.3:** More signals, lower quality
- **Setting 0.5-0.8:** Moderate signals, good quality
- **Setting 1.0+:** Only the strongest momentum shifts

**How it works:**
- Calculates how far OBV is from its 50-bar average (Z-score)
- Only shows signals when this distance is meaningful
- Automatically avoids weak, choppy market conditions

---

### **VISUALS & COLORS GROUP**

**Highlight Crossovers?**
- **Default:** ON
- Master toggle for all signal markers
- Turn OFF to see only the OBV/signal lines

**Apply Ribbon Filling?**
- **Default:** ON
- Colors the space between OBV and signal line
- Green fill = OBV above signal (bullish)
- Red fill = OBV below signal (bearish)
- Provides clear visual trend confirmation
- Turn OFF for minimal chart clutter

---

### **STATS & ZONES GROUP**

**Use Window-Normalized OBV (visual only)?**
- **Default:** ON
- Removes long-term trend from OBV for clearer short-term signals
- Detrends the indicator to highlight recent momentum changes
- **ON:** Better for swing trading and identifying reversals
- **OFF:** Better for trend-following strategies
- Note: Z-Score always uses raw OBV for statistical accuracy

**OBV Normalize Window**
- **Default:** 200 bars
- Lookback period for detrending calculation
- Larger values = more aggressive detrending
- Adjust if you want OBV to oscillate more/less around zero

**Show Z-Score (OBV)?**
- **Default:** ON
- Displays statistical momentum indicator below main chart
- Ranges from -3 to +3 (most data within -2 to +2)
- High Z-Score = Strong buying momentum
- Low Z-Score = Strong selling momentum

**Z-Score Lookback**
- **Default:** 50 bars
- Period for calculating Z-Score mean and standard deviation
- Larger = smoother Z-Score, slower response
- Smaller = noisier Z-Score, faster response

**Show ROC (OBV Momentum)?**
- **Default:** OFF
- Rate of Change indicator for OBV velocity
- Useful for identifying momentum turning points
- Enable if you want to see speed of volume changes

**ROC Lookback**
- **Default:** 14 bars
- Period for ROC calculation

**Show Z-Score StdDev Zones?**
- **Default:** ON
- Shaded regions around zero line showing statistical boundaries
- Inner Zone (±1 Z) = Normal variation
- Outer Zone (±2 Z) = Extreme moves, potential reversals
- Helps identify overbought/oversold volume conditions

**Inner Zone (±Z)**
- **Default:** 1.0
- First boundary for standard deviation zones
- Most normal trading occurs within ±1

**Outer Zone (±Z)**
- **Default:** 2.0
- Second boundary for extreme conditions
- Crossing these zones indicates significant momentum shift

---

## Trading Strategy Examples

### **Strategy 1: Signal Line Crossovers (Beginner)**

**Setup:**
- Signal Filter Type: **Confirmation Bars**
- Confirmation Bars: **2-3**
- Show Signal Markers: **ON**

**Rules:**
1. **BUY signal** (green V): When OBV crosses above signal line and holds for 2-3 bars
- Confirms buying pressure is building
- Look for price to follow within 1-3 bars
2. **SELL signal** (red V): When OBV crosses below signal line and holds for 2-3 bars
- Confirms selling pressure is increasing
- Expect price decline
3. **Exit:** Take profits at next signal or use price support/resistance

**Best For:** Swing trading, intraday reversals, timeframes 5m-1h

---

### **Strategy 2: Zero Line Bounce (Intermediate)**

**Setup:**
- Signal Filter Type: **Strength-Based**
- Min Z-Score Strength: **0.5**
- Show Z-Score StdDev Zones: **ON**

**Rules:**
1. **Watch OBV approach zero line** during established trends
- OBV bouncing repeatedly off zero = trend is healthy
- OBV breaking through zero = trend reversal imminent
2. **Enter on bounce:** Buy when OBV bounces from zero line in uptrend
3. **Exit on break:** Close position when OBV breaks below zero line
4. **Confirm with Z-Score:** Only take trades when Z-Score shows momentum (|Z| > 0.5)

**Best For:** Trend traders, identifying trend strength, medium timeframes 15m-4h

---

### **Strategy 3: Momentum Extremes (Advanced)**

**Setup:**
- Signal Filter Type: **None**
- Show Z-Score StdDev Zones: **ON**
- Outer Zone: **2.0**

**Rules:**
1. **Identify extremes:** When Z-Score breaks outer zone (±2.0)
- Indicator is in extreme territory
- Likely overextended
2. **Fade extremes:** Take opposite position when Z-Score hits extreme
- High Z (>2.0) = OBV overbought, expect pullback
- Low Z (<-2.0) = OBV oversold, expect bounce
3. **Confirm:** Wait for crossover signal to enter
4. **Target:** Outer zone of opposite side or zero line

**Best For:** Range trading, mean reversion, experienced traders only

---

## Reading the Indicator in Different Markets

### **Strong Uptrend**
- OBV consistently above signal line (green)
- OBV well above zero line, rising higher lows
- Z-Score positive, trending upward
- **Action:** Buy dips to signal line, sell at resistance

### **Strong Downtrend**
- OBV consistently below signal line (red)
- OBV well below zero line, making lower highs
- Z-Score negative, trending downward
- **Action:** Sell rallies to signal line, cover at support

### **Consolidation/Choppy Market**
- OBV whipsaws around signal line frequently
- Crossovers occur every few bars
- Z-Score oscillating between -1 and +1
- **Action:** Increase confirmation bars to 3-4, or switch to strength-based filter

### **Accumulation (Bottom Formation)**
- OBV rising while price is flat or falling
- Volume flowing in despite downtrend (bullish divergence)
- Z-Score climbing while price lows hold
- **Action:** Expect breakout up; prepare buy near support

### **Distribution (Top Formation)**
- OBV falling while price is flat or rising
- Volume flowing out despite uptrend (bearish divergence)
- Z-Score falling while price continues higher
- **Action:** Expect breakdown down; prepare short near resistance

---

## Parameter Tuning Guide

### **Aggressive Settings (More Signals)**
- Smoothing Length: 14
- Signal Filter: None or Confirmation Bars: 1
- Min Z-Score: 0.1
- Best for: Day trading, high volatility stocks
- Risk: More false signals

### **Balanced Settings (Recommended)**
- Smoothing Length: 21
- Signal Filter: Confirmation Bars: 2
- Min Z-Score: 0.3
- Best for: Swing trading, most market conditions
- Risk/Reward: Moderate

### **Conservative Settings (Fewer Signals)**
- Smoothing Length: 30-40
- Signal Filter: Confirmation Bars: 3-4 or Strength-Based: 0.7+
- Min Z-Score: 0.8
- Best for: Position trading, high-conviction trades only
- Risk: May miss some moves

---

## Common Questions & Troubleshooting

**Q: Why are there more sell signals than buy signals?**
A: This reflects the actual market action. Markets often decline faster than they rise (fear > greed). Confirm signals with price action and support/resistance.

**Q: The indicator keeps whipsawing, should I hide it?**
A: Increase Confirmation Bars to 3-4 or switch to Strength-Based filter. Market conditions matter—choppy markets require stricter filters.

**Q: What's the difference between normalized and raw OBV?**
A: Normalized (detrended) shows shorter-term momentum by removing long-term trends. Raw OBV shows absolute accumulation/distribution over the full period. Use normalized for swing signals, raw for trend confirmation.

**Q: My signals come too late. How do I get faster entry?**
A: Reduce Smoothing Length (try 14 instead of 21), use EMA instead of SMA, or set Confirmation Bars to 1. Trade-off: More false signals.

**Q: Can I use this for day trading?**
A: Yes, on 1m-5m charts with aggressive settings. Use Confirmation Bars: 1 and focus on Z-Score > 0.5 entries only.

**Q: Should I trade every signal?**
A: No. Filter signals using: price near support/resistance, multiple indicators confirming, and Z-Score showing momentum. Best signals occur at key levels.

---

## Best Practices

1. **Always confirm with price action:** OBV signals work best when price is near support, resistance, or moving average. Don't trade signals in a vacuum.

2. **Use volume context:** Check if volume is increasing or decreasing on the signal. Strong signals have volume confirmation (increasing volume on OBV spikes).

3. **Adjust settings per timeframe:**
- 1m-5m: Smoothing 12, Confirmation 1, Z-Score 0.2
- 15m-1h: Smoothing 20, Confirmation 2, Z-Score 0.3
- 4h-1d: Smoothing 25, Confirmation 3, Z-Score 0.5

4. **Watch the zero line:** It's your friend. OBV behavior at the zero line reveals trend strength. Bounces = healthy trend. Breaks = reversal.

5. **Risk management:** No indicator is perfect. Use proper position sizing and stop losses. OBV should confirm your thesis, not be the only reason to trade.

6. **Combine with other indicators:**
- Price moving averages for trend confirmation
- RSI or Stochastic for overbought/oversold levels
- Support/resistance for entry/exit zones
- MACD for momentum divergences

---

## Disclaimer

This indicator is for educational and informational purposes only. It is not financial advice. Past performance does not guarantee future results. Always conduct your own research and consult with a financial advisor before making trading decisions. Trading carries risk, including potential loss of principal.

---

## Version History

**Version 1.0** - Initial release with enhanced signal filtering, Z-Score analysis, and customizable parameters.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.