OPEN-SOURCE SCRIPT
Volume Z-Score (2 StdDev)

Here's a ready-to-use description for the publish listing:
---
**Volume Z-Score (2 StdDev) — Sell-off vs. Buying Volume Outliers**
This indicator flags statistically unusual volume days by calculating a z-score: how many standard deviations today's volume is from its rolling 20-period average. Rather than relying on a fixed "unusual volume" threshold that doesn't adapt across different stocks or volatility regimes, this calculates the mean and standard deviation dynamically, so the "outlier" bar scales naturally with each symbol's own typical volume behavior.
**How it works:**
- Volume bars are plotted as columns, color-coded by both magnitude and direction:
- **Gray** — normal volume, within 2 standard deviations of the 20-period average
- **Lime green** — volume is 2+ standard deviations above average AND the bar closed up (buying/accumulation pressure)
- **Red** — volume is 2+ standard deviations above average AND the bar closed down (selling/distribution pressure)
- An orange threshold line plots the actual 2-standard-deviation level (average + 2×stdDev), so you can see the dynamic cutoff directly rather than trusting the color alone
- Two separate alert conditions are included: one for sell-off volume outliers, one for buying volume outliers, so you can set alerts independently for either direction
**How to use it:**
Best paired with a volatility-compression indicator like the TTM Squeeze — a squeeze release confirmed by a same-day green (or red) volume outlier here is a stronger signal than a squeeze release with unremarkable volume. Works on any timeframe and any symbol; the 20-period lookback can be adjusted in settings to suit shorter or longer-term analysis.
**Settings:**
- Lookback Length (default 20) — the period used to calculate the rolling average and standard deviation of volume
**Disclaimer:** This is a volatility/volume analysis tool, not a standalone trading system. It does not predict direction with certainty and should be combined with price action, trend context, and proper risk management. Past patterns do not guarantee future results.
---
**Volume Z-Score (2 StdDev) — Sell-off vs. Buying Volume Outliers**
This indicator flags statistically unusual volume days by calculating a z-score: how many standard deviations today's volume is from its rolling 20-period average. Rather than relying on a fixed "unusual volume" threshold that doesn't adapt across different stocks or volatility regimes, this calculates the mean and standard deviation dynamically, so the "outlier" bar scales naturally with each symbol's own typical volume behavior.
**How it works:**
- Volume bars are plotted as columns, color-coded by both magnitude and direction:
- **Gray** — normal volume, within 2 standard deviations of the 20-period average
- **Lime green** — volume is 2+ standard deviations above average AND the bar closed up (buying/accumulation pressure)
- **Red** — volume is 2+ standard deviations above average AND the bar closed down (selling/distribution pressure)
- An orange threshold line plots the actual 2-standard-deviation level (average + 2×stdDev), so you can see the dynamic cutoff directly rather than trusting the color alone
- Two separate alert conditions are included: one for sell-off volume outliers, one for buying volume outliers, so you can set alerts independently for either direction
**How to use it:**
Best paired with a volatility-compression indicator like the TTM Squeeze — a squeeze release confirmed by a same-day green (or red) volume outlier here is a stronger signal than a squeeze release with unremarkable volume. Works on any timeframe and any symbol; the 20-period lookback can be adjusted in settings to suit shorter or longer-term analysis.
**Settings:**
- Lookback Length (default 20) — the period used to calculate the rolling average and standard deviation of volume
**Disclaimer:** This is a volatility/volume analysis tool, not a standalone trading system. It does not predict direction with certainty and should be combined with price action, trend context, and proper risk management. Past patterns do not guarantee future results.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน