Standard Deviation
systemic:core-stdevStatisticsInputs
| Name | Type | Description |
|---|---|---|
| Data | Number series | The series of numbers over which the cumulative standard deviation is computed. |
Outputs
| Name | Type | Description |
|---|---|---|
| StDev | Number series | The cumulative (expanding) standard deviation: each bar covers all data from the start of the series up to that bar. |
Cost
0.198 + 0.00582·n credits for n bars, rounded up. The marks are each plan's limit of bars.
The Standard Deviation module measures how far the values of a series spread around their mean. It does not use a rolling window. It produces an expanding (cumulative) standard deviation: each output value covers all values from the start of the series up to that bar.
Where:
- is the -th value
- is the mean of the first values
- is the standard deviation at bar
Why Cumulative (Expanding) Standard Deviation?
Most traders know the rolling standard deviation: a fixed window that slides forward. This module is different: at each bar, it measures how spread out all data so far has been.
flowchart LR
subgraph Rolling["Rolling StDev (Window = 3)"]
R1["Point 5: uses points 3-5"]
R2["Point 6: uses points 4-6"]
R3["Point 7: uses points 5-7"]
end
subgraph Expanding["Cumulative StDev (This Module)"]
E1["Point 5: uses points 1-5"]
E2["Point 6: uses points 1-6"]
E3["Point 7: uses points 1-7"]
end
| Approach | Behavior | Best For |
|---|---|---|
| Rolling | Fixed memory, forgets old data | Short-term volatility signals |
| Cumulative | Never forgets, stabilizes over time | Historical context, regime detection |
The cumulative approach answers: "How volatile has this asset been since the start of the series?"
How It Works
flowchart TD
subgraph Input["Input Data"]
P["Series of Values (prices, returns, indicators)"]
end
subgraph Process["At Each Point n"]
M["Calculate cumulative mean of points 1...n"]
D["Compute squared deviations from mean"]
V["Average the squared deviations"]
S["Take square root → σ_n"]
end
subgraph Output["Output Series"]
SD["σ_2, σ_3, ... σ_n"]
end
P --> M --> D --> V --> S --> SD
Key property: Early output values move more. As data accumulates, the cumulative standard deviation settles toward the long-term volatility.
Real-World Volatility Comparison
Different assets have very different volatility. Using daily return data from June–December 2024:
| Asset | Daily StDev (σ) | Annualized Volatility |
|---|---|---|
| SPY (S&P 500 ETF) | 0.85% | ~13.4% |
| GLD (Gold ETF) | 1.02% | ~16.1% |
| NVDA (Nvidia) | 3.32% | ~52.7% |
| BTC (Bitcoin) | 3.73% | ~59.3% |
Annualized volatility = Daily σ × √252 (trading days per year)
This shows why position sizing and risk management cannot be the same for every asset: the same dollar amount in BTC carries roughly 4× the volatility of SPY.
Interpreting the Output
| STDEV Behavior | What It Means |
|---|---|
| High values | Wide price swings; the asset is hard to predict |
| Low values | Values stay close to the mean; stable behavior |
| Rising over time | Recent data is more volatile than earlier data |
| Falling / stabilizing | The asset is settling into a consistent range |
The Stabilization Effect
Because the calculation is cumulative, one volatile bar early in the series has a large effect. As the series grows, the effect of that bar shrinks.
xychart-beta
title "Cumulative StDev Stabilization (Conceptual)"
x-axis "Data Points" [10, 50, 100, 200, 500]
y-axis "σ Sensitivity to New Point" 0 --> 15
line "Impact of One Outlier (%)" [10, 4, 2.5, 1.5, 0.8]
Trading Applications
1. Volatility Regime Detection
The cumulative standard deviation is a baseline for "normal" volatility. When short-term volatility (from another module) is far above this baseline, the market may be entering a new regime.
| Condition | Interpretation |
|---|---|
| Short-term σ >> Cumulative σ | Market stress or breakout |
| Short-term σ ≈ Cumulative σ | Normal conditions |
| Short-term σ << Cumulative σ | Unusual calm; potential squeeze |
2. Risk-Adjusted Position Sizing
A basic principle: the higher the volatility, the smaller the position.
For a $10,000 portfolio risking 2% per trade ($200), with an asset priced at $100 and σ = 3%:
Higher volatility → fewer shares. This keeps the dollar risk similar across assets.
3. Historical Volatility Benchmarking
Comparing cumulative volatility across different date ranges helps to find structural changes:
- "Is this asset more volatile in 2024 than it was in 2020-2023?"
- "Has volatility permanently shifted after a major event?"
Combining with Other Modules
Standard deviation is rarely used alone. Consider these combinations:
| Combination | Purpose |
|---|---|
| STDEV + Moving Average | Build custom bands in the style of Bollinger Bands |
| STDEV + Percentile | Rank current volatility vs. history |
| STDEV ÷ Mean (with Divide) | Coefficient of Variation: normalized volatility |
| Price − Mean (with Subtract), then ÷ STDEV | Z-Score: how many σ the price is from the mean |
Missing Data
A bar with no value (closed market, data gap, or an empty value from an earlier module) is never treated as zero:
- The output on a missing bar is empty. No earlier value is carried forward
- Missing bars are skipped, not filled with zero: the calculation continues at the next bar that has a value
- The output is also empty on the first bar that has a value, because one value has no spread. It becomes a number once at least 2 bars have a value
Limitations to Consider
| Limitation | Implication |
|---|---|
| Lagging indicator | Based only on historical data; cannot predict future volatility |
| Assumes stationarity | If the asset's behavior changes fundamentally, old data may mislead |
| Sensitive to outliers | Extreme values (especially early in the series) have a large effect |
| Not directional | A 5% gain and a 5% loss add equally to volatility |
The Bigger Picture: Volatility in Markets
Standard deviation is a cornerstone of modern finance. It is the basis of:
- Modern Portfolio Theory — Risk-return optimization
- Value at Risk (VaR) — Quantifying potential loss
- Sharpe Ratio — Returns per unit of risk
- Options Pricing — Implied vs. realized volatility
Measuring volatility is not only about avoiding risk. It is about pricing risk correctly and finding cases where the market has mispriced it.