OPEN-SOURCE SCRIPT
Atualizado

Volume Z-Score Readout [TSL]

547
Volume Z-Score Readout shows whether the current bar's volume is statistically unusual for this exact time of day — in plain English, in one small box, with no extra pane.

Most volume indicators give you raw bars and a moving average. The interesting question — "is this volume unusual right now, or just normal for 10:15 AM?" — almost never gets answered well. Intraday volume has a strong time-of-day shape. The cash open is always busy. Noon is always quiet. A 3× spike at 9:30 means almost nothing because that's what 9:30 looks like. A 3× spike at noon is genuinely unusual.

This indicator answers that question with a single box on the chart:

z=-0.5 · normal for this time
z=+1.4 · busier than usual
z=+2.6 · unusual for this time
z=+3.8 · extreme for this time
z=-3.0 · unusually quiet

The box color shifts with the band: grey when normal (|z| < 1), blue when notable (|z| < 2), orange when unusual (|z| < 3), red when extreme (|z| ≥ 3).

═══ HOW IT WORKS ═══

For each bar, the script collects the volume at the same time of day from the trailing N sessions, then computes:
z = (current volume - mean) / standard deviation

A z-score of 0 means exactly average for this time. +1 means one standard deviation above average. +3 means three standard deviations above — genuinely unusual.

Because the calculation uses a time-of-day baseline rather than a rolling N-bar window, the indicator is not fooled by the natural rhythm of the session. The 9:30 open and the lunchtime lull are treated as different distributions, each with their own mean and SD.

═══ WHY OVERLAY ═══

This script overlays on the price chart (not in a separate pane) by design. It's meant to run alongside whatever volume indicator you already use — Session Volume Pulse, native volume, Volume Profile, anything. The readout box sits in a corner you pick. Doesn't eat a pane. Doesn't conflict with your existing setup.

If you want the full kit — volume bars colored by spike state, time-of-day baseline line, spike multiplier labels, AND the z-score readout — see Session Volume Pulse [TSL] instead. This standalone is for users who already have a volume display they like and just want the verdict.

═══ FAST SETUP: THREE PRESETS, NO MATH ═══

The settings panel is preset-driven so most users finish setup in two clicks.

PRESET 1 — Trader style (controls how responsive the baseline is)

• Day trader (responsive): 14 sessions. Adapts fast after vol regime shifts. More noise, more alerts. Best for tight intraday work.
• Swing trader (balanced): 21 sessions (~one month). DEFAULT. Best statistical balance for most users on 15m charts.
• Position trader (very stable): 42 sessions (~two months). Slow to adapt. Best when you want band crossings to be rare and meaningful.
• Custom: ignores the preset and uses the numeric "Sessions to average" input below.

PRESET 2 — Market (auto-computes bars-per-session from chart timeframe)

• Auto-detect (24h): correct for crypto, forex, and most ~24h markets.
• Futures (~23h: NQ, ES, CL, GC): for futures traders. Slightly more accurate than Auto.
• US stocks RTH (6.5h): regular trading hours only. For AAPL, MSFT, SPY, etc.
• Custom: ignores the preset and uses the "Bars per session" input below.

PRESET 3 — Sensitivity (controls how often the alert fires)

• Conservative (|z| >= 2.5, ~1/week): only extreme events.
• Balanced (|z| >= 2.0): DEFAULT. Catches notable → unusual transitions, the most actionable threshold on 15m charts.
• Sensitive (|z| >= 1.5, more alerts): many more alerts; use only if you actively want to monitor the busier-than-usual threshold.
• Custom: ignores the preset and uses the "Alert threshold" input below.

═══ DEFAULT BEHAVIOR (15M FUTURES) ═══

With defaults out of the box:
• Trader style: Swing trader (21 sessions)
• Market preset: Auto-detect (24h)
• Sensitivity: Balanced (|z| >= 2.0)
• Readout position: Top right
• Text size: Normal
• Show 'Time-of-day' label cell: Off (compact pill)

Drop the indicator on a 15m NQ chart and it works immediately. No configuration required for the default case. The two "(only if Custom)" numeric inputs below each preset are escape hatches for power users — leave them alone unless you've picked Custom on the related preset.

═══ READING THE VERDICT ═══

The verdict text is direction-aware:

• |z| < 1 → "normal for this time" (grey)
• 1 ≤ |z| < 2 → "busier than usual" / "quieter than usual" (blue)
• 2 ≤ |z| < 3 → "unusual for this time" / "unusually quiet" (orange)
• |z| ≥ 3 → "extreme for this time" / "extreme silence" (red)

A positive z reads "busier"; a negative z reads "quieter." This matters: z=-2.1 isn't ambiguous — it specifically means today's bar is unusually QUIET for this minute. That's often as important as a spike. Distribution days often start with eerily-quiet volume; reversals often begin with silence.

═══ ALERTS ═══

One alert: "Unusual volume" — fires when |z| crosses the resolved threshold (the value picked by the Sensitivity preset, or the Custom input if you picked Custom). Set up in TradingView's alerts panel after adding the indicator.

═══ HONEST LIMITATIONS ═══

• Does not predict price direction. A spike with a green close is bullish confirmation; the same spike with a red close is often capitulation or distribution. Reading direction is on you.
• Does not work on symbols without volume. Most spot forex pairs on retail platforms report tick count, not real volume. For forex volume analysis, use the equivalent futures contract (6E, 6J, 6B) instead.
• Needs history. On a fresh symbol with fewer than N sessions of data (where N is your Trader style setting), the SD calculation may be unstable for the first few sessions. The verdict will read "insufficient history" until samples accumulate.
• DST transitions and holiday-shortened sessions in the lookback window offset the baseline by a bar or two until those sessions roll out of the average.
• Above 1h timeframes, the verdict becomes unreliable. A 4h chart contains only ~6 four-hour bars per futures session — too coarse for stable time-of-day stats. Treat this as a 1m-to-1h tool.

═══ COMPANION TO SESSION VOLUME PULSE ═══

This indicator pairs with Session Volume Pulse [TSL] — same math foundation, different display. SVP includes a z-score toggle (off by default) for users who want everything in one indicator. This standalone exists for users who already have a volume setup they like and just want the verdict.

Note: SVP defaults to 14 sessions (its baseline is tuned for responsiveness). This standalone defaults to "Swing trader" = 21 sessions (tuned for statistical stability of the band crossings). Both choices are intentional — if you run both indicators side by side and want identical numbers, set SVP's "Baseline sessions" to 21 and this script's Trader style to Custom with the same value.

═══ WHY OPEN SOURCE ═══

Closed-source indicators in finance are a known yellow flag — they often do less than claimed or rely on lookahead bias. Every line of this script is readable. Audit the math, fork it, modify it for your strategy. The calculation is intentionally simple.

Pine Script v6, overlay, no repainting. Source visible on this script page.

Disclaimer: This is an analytical tool that displays publicly available volume data with a time-of-day statistical overlay. It does not predict price direction or guarantee any trading outcome. Volume z-score readings can precede continuation, reversal, or no follow-through. Trading futures and equities involves substantial risk of loss. For educational purposes only.
Notas de Lançamento
The script now computes the wall-clock time of day for the current bar (e.g. "9:00 AM = minute 540"), then walks backwards through actual chart history looking for past bars whose wall-clock time is within ± tolerance minutes of that.
What this fixes:

Weekends — Friday 5pm to Sunday 5pm has no bars. The walk simply skips over them. The 5th past matching bar is still 5 trading days back regardless of weekend gaps.
Daily 1-hour break — NQ closes 5pm-6pm ET daily. Those minutes don't have bars. The walk skips them.
Holidays — Christmas, Thanksgiving, etc. Just skipped.
DST transitions — hour() and minute() return chart-local time which handles DST correctly.
Half-day Fridays — afternoon bars don't exist on early-close days; the walk skips them and finds the next valid match.
Notas de Lançamento
The script now computes the wall-clock time of day for the current bar (e.g. "9:00 AM = minute 540"), then walks backwards through actual chart history looking for past bars whose wall-clock time is within ± tolerance minutes of that.
What this fixes:

Weekends — Friday 5pm to Sunday 5pm has no bars. The walk simply skips over them. The 5th past matching bar is still 5 trading days back regardless of weekend gaps.
Daily 1-hour break — NQ closes 5pm-6pm ET daily. Those minutes don't have bars. The walk skips them.
Holidays — Christmas, Thanksgiving, etc. Just skipped.
DST transitions — hour() and minute() return chart-local time which handles DST correctly.
Half-day Fridays — afternoon bars don't exist on early-close days; the walk skips them and finds the next valid match.
Notas de Lançamento
I needed to update the image as it was incorrect previously.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.