# Standard Deviation

Standard Deviation is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Standard Deviation computes the population standard deviation of a selected price source over a lookback window and plots it as a single line, quantifying how far prices deviate from their mean over that period. Defaults are a length of 20 with a configurable source input. This is the plain statistical measure in its raw form, with no bands or smoothing added.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Apr 13, 2020.
- Access: free.
- Concepts: [Standard Deviation](https://www.luxalgo.com/library/concept/standard-deviation/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=htms657mpkgfgihygw8102mb
- Page: https://www.luxalgo.com/library/indicator/standard-deviation/

**Standard Deviation** computes the standard deviation of a selected price source over a lookback window and plots it as a single line, quantifying how far prices deviate from their mean so traders can watch volatility expand and contract directly. Defaults are a length of 20 on the closing price. This is the plain statistical measure in its raw form (no bands, no smoothing, no overlays), and that austerity is the appeal: the line rises when moves get larger, falls when the market tightens, nothing else.

## How to Trade the Standard Deviation?

- **Rising line**: dispersion is expanding; bars are traveling farther from their recent mean, the signature of an active or trending tape.
- **Falling line**: contraction; price is coiling around its average and the market is going quiet.
- **Extreme low readings**: compression phases that squeeze-style traders monitor as the base conditions from which expansions are anticipated.
- **Extreme high readings**: dispersion at its widest, typical of climactic sessions, news shocks, or capitulation bars.
- **No directional content**: the line is unsigned: identical readings can accompany a surge or a collapse, so direction must come from another tool.

Because the value is denominated in price units, its absolute size scales with the instrument's price level; compare readings against the same symbol's own history rather than across markets.

## Standard Deviation Settings

- **Length** (default 20): the number of bars used to compute the standard deviation. Shorter windows react quickly to a single large bar and fade just as fast; longer windows describe the prevailing volatility regime.
- **Source** (default close): the price series the standard deviation is calculated on.

## Frequently Asked Questions

### How is Standard Deviation different from ATR?
ATR averages bar ranges, gaps included, so it measures how large a typical bar is. Standard deviation measures how widely the source values scatter around their own mean, so a market stair-stepping steadily in one direction can show modest deviation despite decent bar sizes.

### How does this relate to Bollinger Bands?
Bollinger Bands are a moving average plus and minus a multiple of exactly this measure, over the same customary 20-period window. Plotting the raw line is effectively plotting the bands' width driver on its own scale, a direct view of compression and expansion instead of inferring them from band shape.

### Does a high reading tell me which way price is going?
No. Standard deviation is unsigned, so a spike says only that prices are scattering widely, equally consistent with a breakout, a breakdown, or violent chop. Pair it with a directional read and treat the volatility line as context for sizing rather than as a signal source.

## Related indicators

- [Reversal Probability Zone & Levels](https://www.luxalgo.com/library/indicator/reversal-probability-zone-levels/) (Percentile Rank): markdown at https://www.luxalgo.com/library/indicator/reversal-probability-zone-levels.md
- [Consecutive Candle Streak Analysis](https://www.luxalgo.com/library/indicator/consecutive-candle-streak-analysis/) (Distribution-of-returns Profiling): markdown at https://www.luxalgo.com/library/indicator/consecutive-candle-streak-analysis.md
- [Probability Grid](https://www.luxalgo.com/library/indicator/probability-grid/) (Distribution-of-returns Profiling): markdown at https://www.luxalgo.com/library/indicator/probability-grid.md
- [Change-Point Detection (CUSUM)](https://www.luxalgo.com/library/indicator/change-point-detection-cusum/) (Outlier Detection): markdown at https://www.luxalgo.com/library/indicator/change-point-detection-cusum.md
- [Standardized Cumulative Deltas](https://www.luxalgo.com/library/indicator/standardized-cumulative-deltas/) (Z-score): markdown at https://www.luxalgo.com/library/indicator/standardized-cumulative-deltas.md
- [Sigmoid Transition Trailing Stop](https://www.luxalgo.com/library/indicator/sigmoid-transition-trailing-stop/) (Sigmoid/softmax Transforms): markdown at https://www.luxalgo.com/library/indicator/sigmoid-transition-trailing-stop.md
- [ATR Exceedance Probability Model](https://www.luxalgo.com/library/indicator/atr-exceedance-probability-model/) (Distribution-of-returns Profiling): markdown at https://www.luxalgo.com/library/indicator/atr-exceedance-probability-model.md
- [Percentile Nearest Rank Using Arrays](https://www.luxalgo.com/library/indicator/percentile-nearest-rank-using-arrays/) (Percentile Rank): markdown at https://www.luxalgo.com/library/indicator/percentile-nearest-rank-using-arrays.md

---

Source: https://www.luxalgo.com/library/indicator/standard-deviation/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
