Standard Deviation (volatility)

Standard Deviation of price over a rolling lookback window. Also known as Historical Volatility (HV). Z-Score is also returned. [Discuss] 💬

chart for Standard Deviation (volatility)

// C# usage syntax
IEnumerable<StdDevResult> results =
  quotes.GetStdDev(lookbackPeriods);

// usage with optional SMA of SD (shown above)
IEnumerable<StdDevResult> results =
  quotes.GetStdDev(lookbackPeriods, smaPeriods);

Parameters

lookbackPeriods int - Number of periods (N) in the lookback period. Must be greater than 1 to calculate; however we suggest a larger period for statistically appropriate sample size.

smaPeriods int - Optional. Number of periods in the moving average of StdDev. Must be greater than 0, if specified.

Historical quotes requirements

You must have at least N periods of quotes to cover the warmup periods.

quotes is a collection of generic TQuote historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

Response

IEnumerable<StdDevResult>

StdDevResult

Date DateTime - Date from evaluated TQuote

StdDev double - Standard Deviation of price

Mean double - Mean value of price

ZScore double - Z-Score of current price (number of standard deviations from mean)

StdDevSma double - Moving average (SMA) of StdDev based on smaPeriods periods, if specified

Utilities

See Utilities and helpers for more information.

Chaining

This indicator may be generated from any chain-enabled indicator or method.

// example
var results = quotes
    .Use(CandlePart.HL2)
    .GetStdDev(..);

Results can be further processed on StdDev with additional chain-enabled indicators.

// example
var results = quotes
    .GetStdDev(..)
    .GetSlope(..);