Strategy · Pine Script v6 · On the chart

VCP Probe 04 Volume Z-Score Anomaly

by pineforge-4pass· code credited to PineForge contributors 2026

A small test strategy from a parity-checking corpus that isolates a volume Z-score calculation.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code52
Settings1inputs
LicenceApache-2.0
Last update6 days ago23 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

52 lines of Pine Script v6 from validation/composite-vcp-vol-zscore-anomaly-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// VCP probe 04 — volume Z-score anomaly
//
// Purpose: isolate the volume-anomaly half of the VCP integration probe
// family. That family computes
// ``volZScore = (volume - volMA) / volStd`` where ``volMA = ta.sma(volume, 20)``
// and ``volStd = ta.stdev(volume, 20)``. ``volAnomaly = math.abs(volZScore) > 2``
// then feeds the volume confluence as a ``+1`` bonus AND multiplies the
// smart-money score by 1.5. A small drift in ``ta.stdev`` (e.g. sample-vs-
// population denominator, or order of summation) shifts the |z|>2 threshold
// crossings and changes WHICH bars trip the anomaly bonus.
//
// This probe routes a trivial entry/exit through ONLY the volume z-score
// anomaly. Any TV/engine drift here is attributable to ``ta.sma(volume, 20)``
// + ``ta.stdev(volume, 20)`` precision at a length matching VCP, NOT to
// VCP's other filters.
//
// Trade shape: long-only, pyramiding=1. Enter long on a high-volume
// bullish anomaly (|z|>2 on an up-bar, ``close > open``). Close the
// long on a high-volume bearish anomaly (|z|>2 on a down-bar).
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. Export the trade list to trades.csv
// in this folder.
//@version=6
strategy("VCP probe 04 - vol zscore anomaly", shorttitle="VCP_p04",
     overlay=true, initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0,
     slippage=0, default_qty_type=strategy.fixed, default_qty_value=1,
     pyramiding=1, process_orders_on_close=false)

// ---- inputs (mirror VCP defaults) ----------------------------------
int i_vol_ma = input.int(20, "Volume MA Length", minval=5, maxval=50)

// ---- volume Z-score — IDENTICAL formula to VCP ---------------------
// Note: VCP hardcodes the stdev length to 20 (line 312). The MA length
// is also 20 by default. Both passes use the same lookback so ``volMA``
// and ``volStd`` are aligned.
float volMA  = ta.sma(volume, i_vol_ma)
float volStd = ta.stdev(volume, 20)
float volZ   = (volume - volMA) / volStd
bool volAnomaly = math.abs(volZ) > 2.0

// ---- trivial entry / exit ------------------------------------------
if volAnomaly and close > open and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=1, comment="vol-z anomaly bull")

if volAnomaly and close < open and strategy.position_size > 0
    strategy.close("L", comment="vol-z anomaly bear exit")

Overview

VCP Probe 04 Volume Z-Score Anomaly compares volume with its moving average and standard deviation, and flags bars where the absolute score is above 2. It enters one long unit on a flagged up bar and closes the position on a flagged down bar. There is no stop loss or take profit, and commission and slippage are zero. The single input sets the volume average length. It is written to check engine behaviour, not as a finished trading tool.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Volume

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Volume MA Lengthint20i_vol_ma
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

257 stars

This overlay strategy is built for ES futures on the one-minute chart. It plots a volume-weighted moving average of price opens and standard-deviation bands at Fibonacci ratios, plus a second longer volume-weighted average from a higher-timeframe open. Call an

Strategy v5 Volatility & bandsMoving averages
Updated 6 weeks ago · None stated GitHub repository of ES Futures 1M No Repaint
218 stars

This strategy enters long when a faster moving average crosses above a slower one and short when it crosses below, unless long-only mode is on. An optional volume filter requires volume above a 20-bar average times a multiplier. Exits use a percentage stop los

Strategy v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of MA Cross Strategy Template
106 stars

This Pine Script strategy identifies potential Buy Today, Sell Tomorrow (BTST) opportunities based on price action and volume patterns. It calculates a 20-period simple moving average of volume and checks for three consecutive bullish candles with higher highs

Strategy v4 TrendVolume
Updated 2 years ago · GPL-3.0 GitHub repository of 3 Higher High Price & Vol
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 5 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

CombinedBinHAndClucV8

by viktors1982
36 stars

This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV8

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers