OPEN-SOURCE SCRIPT
Price*Volume Z-Score Oscillator

Useful for finding statistically significant order blocks for OTM options on stocks. Used to find "informed traders".
To understand the math behind this indicator, we have to break it down into three distinct layers: the **Variable Construction**, the **Central Limit Theorem application**, and the **Z-Transformation**.
---
### 1. The Variable: Dollar Volume (
PV$)
Instead of looking at Price or Volume in isolation, we create a composite variable:
$$PV_t = P_t \times V_t$$
* **$P_t$**: The closing price at time $t$.
* **$V_t$**: The number of shares/contracts traded at time $t$.
This represents the total **nominal value** flowing through the asset. It is a more rigorous measure of market conviction than volume alone because it accounts for the capital required to move the price at that specific level.
---
### 2. The Moving Window (Rolling Statistics)
We don't compare the current
PV$ to the beginning of time; we compare it to a **lookback window** ($n=20$).
#### The Arithmetic Mean ($\mu$)
We calculate the Simple Moving Average of the
PV$ product:
$$\mu_{PV} = \frac{1}{n} \sum_{i=0}^{n-1} PV_{t-i}$$
This establishes the "expected" liquidity environment for the current regime.
#### The Standard Deviation ($\sigma$)
We measure the dispersion (volatility) of the
PV$ product over that same window:
$$\sigma_{PV} = \sqrt{\frac{1}{n} \sum_{i=0}^{n-1} (PV_{t-i} - \mu_{PV})^2}$$
This tells us how much the "Dollar Volume" typically fluctuates. If $\sigma$ is high, the market is erratic; if $\sigma$ is low, the market is consistent.
---
### 3. The Z-Score Transformation
The Z-score is a "dimensionless" number. It strips away the dollar signs and the share counts, leaving only a pure measure of **distance in units of volatility**.
$$Z = \frac{PV_{current} - \mu_{PV}}{\sigma_{PV}}$$
* **If $Z = 0$**: The current Dollar Volume is exactly average.
* **If $Z = 1$**: The current Dollar Volume is 1 Standard Deviation above average.
* **If $Z = 4$**: The current Dollar Volume is an extreme outlier.
---
### 4. The "4 StDev" Threshold (Statistical Significance)
Why is $Z \ge 4$ significant? We use the **Empirical Rule** and **Chebyshev’s Inequality** to understand the probability:
| Z-Score | Probability (Normal Dist.) | Frequency of Occurrence |
| --- | --- | --- |
| **1.0** | 68.2% | Common |
| **2.0** | 95.4% | Significant (95th percentile) |
| **3.0** | 99.7% | Rare (The "Three-Sigma" event) |
| **4.0** | **99.993%** | **Extreme Outlier** |
In a perfectly normal distribution, a Z-score of 4 should only happen roughly **once every 15,000 bars**.
> **The Reality of "Fat Tails":** Financial data is not perfectly normal; it has "leptokurtosis" (fat tails). This means 4 StDev events happen more often than 0.01% in trading. When you see $Z > 4$, you aren't seeing random noise; you are seeing a **non-random liquidity shock**—likely institutional block trades or massive delta-hedging rebalancing.
### Why this matters for your 0DTE research:
In 0DTE options, Gamma is at its peak. A $Z > 4$ event in the underlying
PV$ product suggests a sudden burst of activity that can force market makers to hedge aggressively. Since $Z$ is rolling, the "average" adapts to the day's volatility, ensuring that a "spike" in the morning is measured differently than a "spike" during the slow lunch hour.
To understand the math behind this indicator, we have to break it down into three distinct layers: the **Variable Construction**, the **Central Limit Theorem application**, and the **Z-Transformation**.
---
### 1. The Variable: Dollar Volume (
Instead of looking at Price or Volume in isolation, we create a composite variable:
$$PV_t = P_t \times V_t$$
* **$P_t$**: The closing price at time $t$.
* **$V_t$**: The number of shares/contracts traded at time $t$.
This represents the total **nominal value** flowing through the asset. It is a more rigorous measure of market conviction than volume alone because it accounts for the capital required to move the price at that specific level.
---
### 2. The Moving Window (Rolling Statistics)
We don't compare the current
#### The Arithmetic Mean ($\mu$)
We calculate the Simple Moving Average of the
$$\mu_{PV} = \frac{1}{n} \sum_{i=0}^{n-1} PV_{t-i}$$
This establishes the "expected" liquidity environment for the current regime.
#### The Standard Deviation ($\sigma$)
We measure the dispersion (volatility) of the
$$\sigma_{PV} = \sqrt{\frac{1}{n} \sum_{i=0}^{n-1} (PV_{t-i} - \mu_{PV})^2}$$
This tells us how much the "Dollar Volume" typically fluctuates. If $\sigma$ is high, the market is erratic; if $\sigma$ is low, the market is consistent.
---
### 3. The Z-Score Transformation
The Z-score is a "dimensionless" number. It strips away the dollar signs and the share counts, leaving only a pure measure of **distance in units of volatility**.
$$Z = \frac{PV_{current} - \mu_{PV}}{\sigma_{PV}}$$
* **If $Z = 0$**: The current Dollar Volume is exactly average.
* **If $Z = 1$**: The current Dollar Volume is 1 Standard Deviation above average.
* **If $Z = 4$**: The current Dollar Volume is an extreme outlier.
---
### 4. The "4 StDev" Threshold (Statistical Significance)
Why is $Z \ge 4$ significant? We use the **Empirical Rule** and **Chebyshev’s Inequality** to understand the probability:
| Z-Score | Probability (Normal Dist.) | Frequency of Occurrence |
| --- | --- | --- |
| **1.0** | 68.2% | Common |
| **2.0** | 95.4% | Significant (95th percentile) |
| **3.0** | 99.7% | Rare (The "Three-Sigma" event) |
| **4.0** | **99.993%** | **Extreme Outlier** |
In a perfectly normal distribution, a Z-score of 4 should only happen roughly **once every 15,000 bars**.
> **The Reality of "Fat Tails":** Financial data is not perfectly normal; it has "leptokurtosis" (fat tails). This means 4 StDev events happen more often than 0.01% in trading. When you see $Z > 4$, you aren't seeing random noise; you are seeing a **non-random liquidity shock**—likely institutional block trades or massive delta-hedging rebalancing.
### Why this matters for your 0DTE research:
In 0DTE options, Gamma is at its peak. A $Z > 4$ event in the underlying
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.