Volume Z-Score Strategy by OmegaTools

By OmegaTools

Performance Metrics

Description

Volume Z-Score StrategyOpen-source, volume-weighted statistical momentum strategy with a dual Z-score architecture.OVERVIEWVolume Z-Score measures how far price has stretched from its recent mean, in standard deviations, and then reads that stretch through two different volume lenses. One lens decides when to enter. The other decides when the move is exhausted. Entries and exits therefore use the same price statistic but are weighted by participation in opposite ways.THE LOGIC1. Price Z-scorePine Script®z = (close − SMA(close, N)) / stdev(close, N)This normalizes displacement by the current volatility regime. A +3 reading means the same statistical stretch in a quiet market as in a volatile one, so a single threshold is comparable across regimes and instruments.2. Volume factorRelative volume is Pine Script®rvol = volume / SMA(volume, N). It is clamped through two envelopes, a narrow one (0.5–2.0) and a wide one (0.33–3.0), and the two results are averaged. The result is a bounded, smooth weight that keeps a single volume spike from dominating the signal.3. Dual Z-scoresEntry Z = z / volumeFactor: opens positions. A stretch on thin volume is amplified, while a stretch on heavy volume is dampened. Entries favor displacement that happens without heavy participation.Exit Z = z × volumeFactor: closes positions (exhaustion). A stretch on heavy volume is amplified. A move that reaches the threshold on climactic volume is treated as exhausted and closed.The same stretch is therefore read opposite ways. Low participation makes it more significant for entry, and high participation makes it more significant for exit. The Invert Volume Weighting option swaps the two roles for markets where the opposite relationship holds.4. SignalsLong entry: Entry Z rises above +threshold.Short entry: Entry Z falls below −threshold.Exhaustion exit: Exit Z crosses the threshold in the direction of the open trade.Opposite signal: a fresh signal in the other direction closes the open position, even when that side is disabled or filtered out.FILTERS AND RISK CONTROLSDirection: Both, Long Only, or Short Only.Trading session: configurable window with its own timezone. An optional setting flattens positions outside the session.Trend filter: Off, With Trend, or Counter-Trend, using a configurable MA length (default 252).ATR stop loss and take profit: optional, as multiples of the ATR measured at entry.Max bars in trade: optional time stop.VISUALSEntry Z plotted as a gradient-coloured line, with exit-Z columns and threshold bands in the lower pane.Position-state background shading.Optional trend MA, signal markers and bar colouring on the price chart.Compact dashboard with the current Z values, volume factor, position, trend state and session status. Theme and position are configurable.Fully customizable palette.USAGE NOTESLookback and threshold are the two main parameters. Higher thresholds trade less often and need stronger statistical displacement.The strategy is designed to be tuned per instrument and timeframe. Different markets can respond best to different direction and trend settings.Alert messages are included on entries and exits for webhook or automation use.OPEN SOURCEThe code is open and commented. Fork it, adapt the weighting function, or use the Z-score and volume-factor modules in your own scripts.This script is provided for educational and research purposes only and is not financial advice. Trading involves substantial risk. Always apply your own testing, costs and risk management.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView