Define the price, window, and denominator
For N consecutive chart bars, let x be each closing price, m their arithmetic mean, and Q the sum of (x − m)². The population convention describes the selected window using divisor N. The sample convention uses N − 1. Both are usable conventions for a descriptive rolling indicator, but switching between them changes the score. Require N ≥ 2.
- With the same nonconstant window, sample Z = population Z × sqrt((N − 1) / N). The larger sample denominator reduces the absolute score.
- A price Z-score and a return Z-score answer different questions. Replacing closes with percentage changes measures an unusual return, not distance of the price level from its average.
- Including the current close lets that observation move both the mean and the deviation. Comparing it with the previous N closes instead creates a different, prior-window score. Label that change explicitly.
| Quantity | Population convention | Sample convention |
|---|---|---|
| Mean m | Sum of closes / N | Same mean |
| Variance | Q / N | Q / (N − 1) |
| Standard deviation | sqrt(Q / N) | sqrt(Q / (N − 1)) |
| Current price score | (current close − m) / population SD | (current close − m) / sample SD |