OPEN-SOURCE SCRIPT

Volume Displacement Engine [JOAT]

1 237
Volume Displacement Engine [JOAT]

Introduction

Volume Displacement Engine (VDE) is an open-source volume regime oscillator that measures the ratio of short-term volume activity to long-term volume baseline, smooths it into a clean oscillator, and classifies current market activity into four distinct regimes: Low, Normal, High, and Extreme. The histogram and background tint update in real time with regime-specific coloring, reference lines mark each threshold boundary, and breakout signals fire when price closes beyond a rolling high or low during elevated volume regimes. A consolidation detection layer identifies consecutive low-volume bars as ranging periods. Trade outcomes from breakout signals are tracked for statistical win rate context, displayed in a structured dashboard.

The core problem VDE solves is the absence of context in standard volume indicators. Raw volume bars communicate size but not relevance — a large bar on a trending instrument in a high-liquidity session is very different from the same bar during off-hours. By expressing volume as a ratio to a rolling baseline and classifying it into regimes, VDE communicates whether current activity is institutionally significant (High or Extreme) or routine (Normal/Low). Price breakouts during High or Extreme volume are fundamentally different propositions than the same price moves on thin volume — VDE makes that distinction explicit and actionable.

Snapshot

Core Concepts

1. Volume Ratio Oscillator

The core calculation divides a short-term volume simple moving average by a long-term volume simple moving average, then applies an EMA smoothing pass to reduce bar-to-bar noise:

Pine Script®
float rawRatio = volShort / math.max(volLong, 1.0) float volRatio = ta.ema(rawRatio, i_smoothLen)


A ratio above 1.0 means recent volume is above the long-term average — activity is elevated. A ratio below 1.0 means recent volume is below the baseline — activity is depressed. The smoothing EMA gives the oscillator a cleaner shape while maintaining responsiveness to regime changes.

2. Four-Tier Regime Classification

Four threshold boundaries define the regime tiers. All thresholds are fully configurable:

  • Low: Ratio below the low threshold (default: 0.70) — below-average activity, reduced institutional participation
  • Normal: Ratio between low and normal ceiling (default: 0.70–1.20) — baseline activity
  • High: Ratio between normal ceiling and high threshold (default: 1.20–1.80) — elevated activity, potential institutional flow
  • Extreme: Ratio above the high threshold (default: 1.80+) — exceptional volume surge, likely significant price event


3. Breakout Signal Detection

Breakout signals are generated when price closes beyond the rolling highest high or lowest low of the configurable lookback window during a High or Extreme volume regime. This combines price displacement with volume confirmation, filtering out low-conviction breakouts that occur on thin volume:

Pine Script®
bool bullBreak = barstate.isconfirmed and close > hh and (isHigh or isExtreme) bool bearBreak = barstate.isconfirmed and close < ll and (isHigh or isExtreme)


4. Consolidation Detection

When multiple consecutive bars fall below the consolidation volume threshold, VDE identifies the period as a consolidation zone. The minimum bar count ensures short dips below the threshold are not misclassified as ranges. A dotted reference line marks consolidation periods in the oscillator pane, providing context for identifying compression before expansion moves.

5. Gradient Fill and Regime Tint

The oscillator histogram is colored to match the current regime. A fill between the histogram and the 1.0 baseline uses the regime color with transparency, providing a visual area representation of volume expansion or contraction. During High and Extreme regimes, a background tint activates in the oscillator pane to immediately draw attention to elevated activity periods without requiring inspection of the histogram height.

Features

  • Volume Ratio Oscillator: Short/long MA ratio smoothed by EMA — measures relative volume displacement from baseline
  • Four-Tier Regime Classification: Low, Normal, High, and Extreme regimes with independent color coding and configurable thresholds
  • Histogram Coloring: Bar color matches current regime — immediate visual reading of activity level
  • Regime Background Tint: High and Extreme volume periods highlighted with a pane background color for immediate attention
  • Threshold Reference Lines: Horizontal dashed lines at each regime boundary and at the 1.0 baseline for quick ratio reading
  • Gradient Regime Fill: Fill between oscillator and baseline communicates expansion/contraction area visually
  • Price Breakout Signals: Bull and bear breakout signals fire when price closes beyond rolling extremes during elevated volume regimes only
  • Consolidation Detection: Consecutive below-threshold volume bars identified as consolidation periods
  • Breakout Win Rate Tracking: Outcomes from breakout signals tracked against ATR-based TP/SL levels for statistical context
  • Non-Repainting: All signals gated on barstate.isconfirmed
  • Dashboard (Top Right): Current regime label, vol ratio value, consolidation status, and win rate breakdown for High and Extreme regime breakouts
  • Vol Momentum Columns: 3-bar rate-of-change of the vol ratio displayed as green/red column bars in the oscillator pane — shows whether volume activity is accelerating or decelerating relative to 3 bars prior
  • Rolling 20-Bar Vol Ratio Peak Reference Line: A purple reference line tracks the rolling 20-bar peak vol ratio — provides a visual ceiling for recent activity levels and highlights when the current ratio is approaching or exceeding recent extremes
  • Vol Ratio Delta in Dashboard: Vol ratio delta shown in real time in the dashboard with a directional arrow (▲/▼) — communicates whether volume pressure is building or fading on the current bar
  • CONS Label on Consolidation Start: A "CONS" label fires at the bar when a consolidation zone begins — marks the exact start of identified compression periods directly on the oscillator
  • Breakout Strength Labels: "BRK +X.XX" and "BRK -X.XX" labels appear at each breakout signal showing the vol ratio value at the moment of the break — communicates the institutional conviction level behind each breakout directly on the chart


Input Parameters

Volume Engine:
  • Short Vol Window: Short-term volume MA period (default: 10)
  • Long Vol Window: Long-term volume MA period (default: 40)
  • Ratio Smooth: EMA smoothing length for ratio (default: 3)
  • Low Vol Threshold: Ratio below which regime is Low (default: 0.70)
  • Normal Vol Ceiling: Ratio above which regime is High (default: 1.20)
  • High Vol Threshold: Ratio above which regime is Extreme (default: 1.80)


Consolidation:
  • Consolidation Window: Lookback window for consolidation range (default: 8)
  • Consolidation Vol Max: Maximum ratio to qualify as a consolidation bar (default: 0.80)
  • Min Consolidation Bars: Minimum consecutive qualifying bars to declare consolidation (default: 4)


Breakout Signal:
  • Breakout Lookback: Rolling high/low lookback window (default: 20)
  • ATR Length: Period for ATR calculation (default: 14)
  • ATR SL Multiplier: Stop loss distance (default: 1.5)
  • Reward:Risk Ratio: TP multiple (default: 3.0)
  • Show TP/SL Labels: Toggle label display in the oscillator pane (default: enabled)


How to Use This Indicator

Step 1: Read the Regime
Glance at the dashboard regime label and histogram color. A grey histogram (Low) indicates the market is in a quiet, low-participation period — avoid breakout strategies during these windows. A teal histogram (Normal) is baseline. An amber histogram (High) or red (Extreme) signals institutional-grade activity.

Step 2: Identify Consolidation Periods
When the dotted consolidation line is active in the oscillator pane, the market is in a low-volume compression phase. These periods typically precede expansion moves — the direction of the subsequent breakout, confirmed on volume, is a key signal.

Step 3: React to Breakout Signals
Breakout signals (triangles at the top/bottom of the oscillator pane) only fire during High or Extreme regimes. When a bull breakout label appears, price has closed above the rolling high on elevated volume — a confirmed displacement. The ATR TP/SL levels from that bar define the immediate risk/reward.

Step 4: Monitor the Ratio Trend
The oscillator line trending upward while above 1.0 indicates sustained institutional accumulation of activity — these sustained elevated periods often coincide with trending phases. A declining ratio from Extreme back toward Normal often signals activity exhaustion.

Indicator Limitations

  • Volume data quality varies significantly by instrument and data provider. On synthetic instruments, indices, or assets where volume reflects contract count rather than notional size, the ratio will not accurately represent true monetary volume displacement
  • TP/SL outcome tracking in the oscillator pane uses price data for TP/SL hit detection but displays in the volume pane — the label positions are approximate visual markers, not precise price levels on the main chart
  • The consolidation detector uses a fixed volume threshold. In trending markets where baseline volume rises over time, the historical consolidation threshold may not match current market conditions without recalibrating the threshold input
  • Breakout signals require both a price breakout and an elevated volume regime simultaneously. In markets with persistently high volume baselines (e.g., during major economic event periods), the Extreme threshold may trigger more frequently than on typical days — the thresholds may need upward adjustment on those instruments
  • The short/long MA window ratio is a relative measure. It compares recent volume to a historical baseline — it does not measure absolute volume in shares, contracts, or dollars


Originality Statement

VDE combines a smoothed relative volume ratio oscillator with a four-tier classification framework, consolidation detection, and volume-gated breakout signals in a unified indicator. This is original for the following reasons:

  • Expressing volume as a ratio of short-term to long-term moving average — rather than showing raw volume bars — normalizes the oscillator across instruments and timeframes, making the same threshold values meaningful on a liquid equity, a commodity, and a cryptocurrency without manual recalibration
  • The four-tier classification system with independently configurable thresholds and a gradient color scheme provides a richer regime reading than simple volume-above-average/below-average binary indicators
  • Volume-gated breakout detection explicitly requires the price breakout and the volume regime elevation to occur simultaneously on the same confirmed bar — preventing breakout signals from firing on thin-volume price moves that carry low institutional conviction
  • The consolidation detection layer adds a compression-identification capability within the volume pane, providing context for identifying low-activity ranging periods before the volume regime shifts to support a directional move


Disclaimer

This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Trading involves substantial risk of loss. Volume regime classification and breakout signals are statistical constructs — elevated volume at a price breakout does not guarantee continuation in the breakout direction. Win rate statistics are derived from historical bar data and do not predict future performance. Always apply proper risk management. The author is not responsible for any trading losses resulting from the use of this indicator.

-Made with passion by jackofalltrades

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.