mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 09:38:05 +00:00
188 lines
7.5 KiB
Markdown
188 lines
7.5 KiB
Markdown
# AOBV: Archer On-Balance Volume
|
|
|
|
> *OBV told me what was happening. AOBV told me when to act.*
|
|
|
|
| Property | Value |
|
|
| ---------------- | -------------------------------- |
|
|
| **Category** | Volume |
|
|
| **Inputs** | OHLCV bar (TBar) |
|
|
| **Parameters** | None |
|
|
| **Outputs** | Multiple series (LastFast, LastSlow) |
|
|
| **Output range** | Unbounded |
|
|
| **Warmup** | `> SlowPeriod` bars |
|
|
| **PineScript** | [aobv.pine](aobv.pine) |
|
|
|
|
- Archer On-Balance Volume (AOBV) applies dual exponential smoothing to the classic On-Balance Volume indicator, creating a responsive yet noise-filt...
|
|
- No configurable parameters; computation is stateless per bar.
|
|
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
|
|
|
Archer On-Balance Volume (AOBV) applies dual exponential smoothing to the classic On-Balance Volume indicator, creating a responsive yet noise-filtered momentum signal. The intersection of fast and slow EMAs provides actionable crossover signals while preserving OBV's core insight: volume precedes price.
|
|
|
|
Developed by EverGet (known as "Archer" in the TradingView community), AOBV addresses OBV's fundamental weakness—its sensitivity to single high-volume bars that can distort the cumulative reading. By smoothing with EMAs of period 4 (fast) and 14 (slow), AOBV filters noise while maintaining responsiveness to genuine accumulation/distribution shifts.
|
|
|
|
## Historical Context
|
|
|
|
On-Balance Volume (OBV) was introduced by Joseph Granville in his 1963 book "Granville's New Key to Stock Market Profits." The premise was elegant: volume is the fuel that drives price moves. If price rises on high volume, the smart money is accumulating. If it falls on high volume, they're distributing.
|
|
|
|
Traditional OBV has one critical flaw: it's cumulative and unbounded, making a single aberrant volume bar (earnings, news events) create permanent distortion. AOBV solves this by applying EMAs—not to smooth the OBV value itself, but to create a dual-line system where crossovers filter false signals.
|
|
|
|
The choice of periods 4 and 14 follows the Fibonacci-adjacent philosophy common in technical analysis. Period 4 captures roughly a week of market action; period 14 represents roughly three weeks. This creates natural separation between short-term noise and medium-term trends.
|
|
|
|
## Architecture & Physics
|
|
|
|
AOBV is a three-stage pipeline:
|
|
|
|
### 1. OBV Accumulation
|
|
|
|
The foundation is standard OBV logic:
|
|
|
|
- If today's close > yesterday's close: add volume
|
|
- If today's close < yesterday's close: subtract volume
|
|
- If closes are equal: add nothing
|
|
|
|
This creates a running sum that rises during accumulation and falls during distribution.
|
|
|
|
### 2. Fast EMA (Period 4)
|
|
|
|
$$
|
|
\alpha_{fast} = \frac{2}{4 + 1} = 0.4
|
|
$$
|
|
|
|
The fast EMA responds quickly to OBV changes, capturing short-term accumulation/distribution shifts.
|
|
|
|
### 3. Slow EMA (Period 14)
|
|
|
|
$$
|
|
\alpha_{slow} = \frac{2}{14 + 1} \approx 0.1333
|
|
$$
|
|
|
|
The slow EMA provides the trend baseline. When fast crosses above slow, it signals strengthening accumulation; crossing below signals distribution.
|
|
|
|
## Mathematical Foundation
|
|
|
|
### OBV Calculation
|
|
|
|
$$
|
|
OBV_t = \begin{cases}
|
|
OBV_{t-1} + V_t & \text{if } C_t > C_{t-1} \\
|
|
OBV_{t-1} - V_t & \text{if } C_t < C_{t-1} \\
|
|
OBV_{t-1} & \text{if } C_t = C_{t-1}
|
|
\end{cases}
|
|
$$
|
|
|
|
where:
|
|
|
|
- $C_t$ = Close price at time t
|
|
- $V_t$ = Volume at time t
|
|
|
|
### EMA with Warmup Compensation
|
|
|
|
Standard EMA suffers from initialization bias. AOBV uses exponential compensation:
|
|
|
|
$$
|
|
\beta_{fast} = 1 - \alpha_{fast} = 0.6
|
|
$$
|
|
|
|
$$
|
|
\beta_{slow} = 1 - \alpha_{slow} \approx 0.8667
|
|
$$
|
|
|
|
For each bar, the compensation factor evolves:
|
|
|
|
$$
|
|
e_{fast,t} = e_{fast,t-1} \times \beta_{fast}
|
|
$$
|
|
|
|
$$
|
|
c_{fast,t} = \frac{1}{1 - e_{fast,t}}
|
|
$$
|
|
|
|
The compensated EMA:
|
|
|
|
$$
|
|
EMA_{raw,t} = \alpha \cdot OBV_t + (1 - \alpha) \cdot EMA_{raw,t-1}
|
|
$$
|
|
|
|
$$
|
|
EMA_{compensated,t} = EMA_{raw,t} \times c_t
|
|
$$
|
|
|
|
This eliminates warmup bias, providing accurate values from the first bar.
|
|
|
|
### Signal Interpretation
|
|
|
|
- **Fast > Slow**: Bullish momentum, accumulation strengthening
|
|
- **Fast < Slow**: Bearish momentum, distribution strengthening
|
|
- **Crossover up**: Buy signal
|
|
- **Crossover down**: Sell signal
|
|
- **Divergence**: Price making new highs/lows while AOBV fails to confirm
|
|
|
|
## Performance Profile
|
|
|
|
### Operation Count (Streaming Mode)
|
|
|
|
| Operation | Count | Notes |
|
|
| :--- | :---: | :--- |
|
|
| CMP | 2 | Close comparison for OBV direction |
|
|
| ADD/SUB | 3 | OBV update, EMA updates |
|
|
| MUL | 8 | Alpha/beta calculations, compensation |
|
|
| DIV | 2 | Compensation factors |
|
|
| FMA | 2 | EMA calculations via FusedMultiplyAdd |
|
|
| **Total** | ~17 | Per bar |
|
|
|
|
### Memory Footprint
|
|
|
|
| Component | Bytes | Notes |
|
|
| :--- | :---: | :--- |
|
|
| State struct | ~88 | 11 doubles (OBV, EMAs, betas, compensators, etc.) |
|
|
| Previous state | ~88 | For bar correction rollback |
|
|
| **Total** | ~176 | Per instance |
|
|
|
|
### Quality Metrics
|
|
|
|
| Metric | Score | Notes |
|
|
| :--- | :---: | :--- |
|
|
| **Accuracy** | 10/10 | Matches PineScript reference exactly |
|
|
| **Timeliness** | 8/10 | Fast EMA (period 4) responds within 2-3 bars |
|
|
| **Overshoot** | 6/10 | Unbounded like OBV; EMAs dampen but don't eliminate |
|
|
| **Smoothness** | 7/10 | EMAs filter noise; dual-line reduces whipsaws |
|
|
| **Allocations** | 0 | Zero heap allocations in Update path |
|
|
|
|
## Validation
|
|
|
|
| Library | Status | Notes |
|
|
| :--- | :---: | :--- |
|
|
| **TA-Lib** | N/A | Has OBV but not AOBV |
|
|
| **Skender** | N/A | Has OBV but not AOBV |
|
|
| **Tulip** | N/A | Has OBV but not AOBV |
|
|
| **Ooples** | N/A | Has OBV but not AOBV |
|
|
| **TradingView** | ✅ | Reference implementation by EverGet |
|
|
|
|
AOBV is a proprietary indicator. Validation is performed against internal consistency checks:
|
|
|
|
- Streaming matches batch calculation
|
|
- Span API matches streaming
|
|
- Fast EMA is more responsive than slow EMA
|
|
- Warmup compensation produces stable early values
|
|
|
|
## Common Pitfalls
|
|
|
|
1. **Warmup Period**: AOBV uses warmup compensation, so values are valid from bar 1. However, `IsHot` only returns true after `SlowPeriod` (14) bars to indicate statistical stability.
|
|
|
|
2. **Scale Interpretation**: AOBV values are in volume units (potentially millions for high-volume stocks). Compare relative changes and crossovers, not absolute values.
|
|
|
|
3. **Dual Output**: AOBV produces two values (FastEMA, SlowEMA). The `Last` property returns FastEMA as the primary signal, but trading strategies typically use both for crossover detection.
|
|
|
|
4. **Volume Quality**: Like all volume indicators, AOBV is only as reliable as the underlying volume data. Crypto wash trading, pre/post-market volume, or adjusted historical data can produce misleading signals.
|
|
|
|
5. **Fixed Parameters**: Unlike configurable indicators, AOBV uses hardcoded periods (4, 14) matching the original specification. This is intentional—the periods were chosen for their signal characteristics.
|
|
|
|
6. **isNew Parameter**: Bar correction (isNew=false) properly rolls back state. This is critical for live trading where the current bar updates multiple times before closing.
|
|
|
|
7. **TValue Not Supported**: AOBV requires OHLCV data (TBar). Attempting to call Update(TValue) throws NotSupportedException.
|
|
|
|
## References
|
|
|
|
- Granville, J. (1963). *Granville's New Key to Stock Market Profits*. Prentice-Hall.
|
|
- EverGet. "Archer On-Balance Volume (AOBV)." TradingView Script Library.
|
|
- StockCharts. "On Balance Volume (OBV)." [Technical Indicators](https://school.stockcharts.com/doku.php?id=technical_indicators:on_balance_volume_obv) |