How it is calculated
The population standard deviation of the source over the last length bars: the mean first, then the square root of the average squared distance from it, dividing by n and not n minus 1. It is computed in two passes, so a flat window can give a rounding residue near 1e-16 rather than exactly 0. As TA-Lib STDDEV with nbdev 1.
Reference: TA-Lib STDDEV
How to read it
Rising values mean price is straying further from its average, falling values a calmer market. Like ATR it is in price units and shows no direction. It reads one price per bar, so with the default close a bar's high and low play no part.
In a strategy
Derive distances or sizes from volatility, for example a stop 1.5 times ctx.ind("stddev", length=20) away from the entry, or a filter that skips trades while it is below its own average.
Inputs
| Input | Type | Default | Range or choices |
|---|---|---|---|
Lengthlength | Whole number | 20 | min 2, max 5000 |
Sourcesource | Price | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
What it draws
| Line | Drawn as |
|---|---|
| StdDev | Line |
Used in
No strategy template reads it yet.