Volatility
Standard Deviation Calculator (Price Series)
Paste a series of prices and get the mean, variance, and standard deviation, both the population version that Pine Script's ta.stdev uses and the sample version.
What standard deviation is
Standard deviation measures how widely a set of values is spread around its average. To calculate it, find the mean, take each value's difference from the mean, square those differences, average them to get the variance, and then take the square root so the result is back in the same units as the prices.
There are two versions. The population version divides the sum of squared differences by n, and the sample version divides by n − 1. Which is appropriate depends on whether your values are the whole set you care about or a sample from a larger one. With only a few values the two differ noticeably, and as the series grows they converge.
Where it shows up in trading analysis
Standard deviation is a building block of several well-known tools. Bollinger Bands place bands a chosen number of standard deviations above and below a moving average, and the Sharpe ratio divides excess return by the standard deviation of returns. It is a descriptive statistic of past data, and how you use it is your own decision.
Note that raw prices drift, so the deviation of a price series mixes trend with noise. Many analysts apply it to returns instead. This tool simply calculates it for whatever series you paste.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
This calculator works on one pasted series. On a chart you would want a rolling value recalculated each bar. In Pine Script that is ta.stdev(close, 20), which uses the population formula, so converting to the sample version needs the extra step shown above.
//@version=6
indicator("Standard Deviation", overlay=false)
length = input.int(20, "Length", minval=1)
src = input.source(close, "Source")
// ta.stdev is the population (biased) standard deviation, dividing by length
popDev = ta.stdev(src, length)
// Sample standard deviation applies Bessel's correction: multiply by sqrt(n / (n - 1))
sampleDev = length > 1 ? popDev * math.sqrt(length / (length - 1)) : na
plot(popDev, "Population stdev", color=color.blue)
plot(sampleDev, "Sample stdev", color=color.orange)PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.