◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / Standard Deviation
Volatility indicator

Standard Deviation

A statistical measure of how far price has spread from its own moving average over a chosen lookback.

Illustrative diagram — not live market data.

What it is

Standard Deviation (often shown as "StdDev" or "StDev") is a volatility indicator borrowed from statistics. It measures how widely a set of values is dispersed around their average. Applied to a chart, it takes the closing prices over a lookback window, finds their moving average, and then quantifies how far, on average, those closes have strayed from that average. The result is plotted as a single line in a separate pane. Because it is a measure of dispersion, it cannot be negative — its lowest possible value is zero, which would only occur if every close in the window were identical. A high reading means recent prices have been spread out — large swings around the average. A low reading means prices have stayed tightly clustered near their average — a quiet, range-bound stretch. Standard Deviation is a building block for other tools: it is the engine behind Bollinger Bands, and it appears inside many volatility-adjusted indicators. On its own it is purely descriptive. It tells you how much price has moved relative to its recent norm, not which direction price moved or where it is going next. It is best understood as a "noise meter" for the market, not a direction tool.

How it works

For each bar, the indicator looks back over a fixed number of periods (the length). It calculates the moving average of the source values (typically the close) over that window. It then measures the difference between each close and that average, squares each difference, averages those squared differences, and takes the square root of the result. Squaring keeps positive and negative deviations from cancelling out and gives extra weight to larger excursions; the square root returns the figure to the same units as price. Note that most charting implementations — including TradingView's ta.stdev — use the population formula, dividing by the number of periods (N) rather than the sample formula (N minus 1), so readings from different platforms can differ slightly. The output is expressed in the instrument's own price units (for example, pips or points), which means readings are not directly comparable across instruments with very different price scales. Because the calculation re-runs on every bar using only the most recent window, the line rises as recent price swings widen and falls as the market settles into a tighter range.

How traders read it

Common settings

Length defaults to 20 periods, which mirrors the lookback used by Bollinger Bands. Shorter lengths (for example 10) make the line more responsive but noisier; longer lengths (for example 50) smooth it and emphasise broader volatility regimes. Source is usually the close, but some traders apply it to hl2 or other series.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("Standard Deviation", overlay = false)

length = input.int(20, "Length", minval = 1)
src    = input.source(close, "Source")

// ta.stdev uses the population standard deviation (divides by N)
stdev = ta.stdev(src, length)

plot(stdev, "StdDev", color = color.teal, linewidth = 2)

Pro tip: Because Standard Deviation is reported in price units, comparing today's reading to the same instrument's own past readings is more informative than judging the raw number in isolation. Some traders pair it with a directional tool to separate "how much price is moving" from "which way" — but remember nothing here is predictive, this is for educational purposes only, and all trading carries the risk of loss.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro