Indicators/probuilder · probacktest · proorder · proscreener

STD

STD in ProBuilder returns the standard deviation of a price series over N bars, the volatility measure behind Bollinger Bands. Syntax, formula, examples.

Syntax

probuilder
STD[N](price)

Parameters

NameTypeDefaultDescription
Ninteger20Number of bars in the calculation window. Common values are 10 and 20.
priceprice sourcecloseThe series whose dispersion is measured. Accepts close, open, high, low, or any custom variable.

Formula

code
STD = SQRT( ( sum from d = 1 to N of (price - Average[N](price))^2 ) / N )

Each of the last N values is compared with the simple moving average of the window, the differences are squared, averaged, and the square root brings the result back to price units.

How it works

Standard deviation quantifies dispersion. On every bar, ProBuilder takes the N most recent values of price, computes their simple average, and measures how far each value strays from that average. Squaring the deviations makes large excursions count disproportionately, so a single wide-range bar lifts the reading noticeably.

Because the result is expressed in the same units as the input, it plugs directly into price-based constructions. The best-known one is the Bollinger Band pair, which plots a moving average plus and minus two standard deviations. STD exposes the raw component so custom band widths, position-sizing rules, or volatility filters can be built from it.

The reading is absolute, not relative. An STD of 5 points is large on an instrument trading at 100 and negligible on one trading at 20,000. For cross-instrument comparisons, divide by price or by the moving average to obtain a relative measure.

Examples

Example 1, Raw volatility line (Indicator)

probuilder
mySeries = close
// Dispersion of the close over the last 10 bars
statisticalDeviation = STD[10](mySeries)
RETURN statisticalDeviation

Calculates and plots the 10-period standard deviation of closing prices, a direct volatility gauge.

Example 2, Volatility filter for entries (ProOrder)

probuilder
// Only trade breakouts when volatility is above its own average
vol     = STD[20](close)
volBase = Average[100](vol)

IF NOT OnMarket THEN
  IF vol > volBase AND close CROSSES OVER highest[20](high[1]) THEN
    BUY 1 CONTRACT AT MARKET
  ENDIF
ELSE
  SELL AT TRAILING vol * 2
ENDIF

Requires the 20-period STD to exceed its 100-bar average before taking a breakout, then trails the exit at twice the current deviation.

Example 3, Volatility contraction scan (ProScreener)

probuilder
// Find instruments whose dispersion has compressed
volNow  = STD[20](close)
volPast = STD[20](close[20])
squeeze = volNow < volPast * 0.5
SCREENER[squeeze]((volNow / close) * 100 AS "STD %")

Lists instruments whose current 20-bar standard deviation is less than half its level 20 bars ago, displayed as a percentage of price for comparability.

Interpretation

  • Rising STD. Price is dispersing away from its average, typical of breakouts, panics, and trending phases.
  • Falling STD. Price is compressing around its average, typical of consolidation. Extended contractions often precede expansions, which is the premise of squeeze-style setups.
  • Bands and channels. A moving average plus and minus k * STD frames a volatility-adjusted channel; k = 2 reproduces standard Bollinger Bands.

STD measures magnitude of movement, not direction. A high reading says nothing about whether price is rising or falling.

Common errors and gotchas

  • Comparing raw STD across instruments. The value is in price units, so it scales with the instrument's price level. Normalise by price before ranking instruments by volatility.
  • Window shorter than expected data. With N larger than the number of loaded bars, early values are computed on incomplete history. Results on the first bars of a chart or backtest are unreliable.
  • Direction assumptions. Filtering for low STD does not select quiet uptrends specifically, it selects quiet anything. Combine with a directional condition when trend context matters.
  • Confusing STD and STE. STD measures dispersion around a moving average; STE measures dispersion around a linear regression line. They answer different questions and diverge in trending markets.
  • STE, standard error around the regression line.
  • BollingerUp, upper Bollinger Band, average plus two standard deviations.
  • BollingerDown, lower Bollinger Band, average minus two standard deviations.
  • BollingerBandWidth, distance between the bands, a derived volatility gauge.
  • Average, the simple moving average at the centre of the calculation.
  • Volatility, alternative built-in volatility estimate.
  • HistoricVolatility, annualised statistical volatility.
  • AverageTrueRange, range-based volatility measure, less sensitive to gaps in the close series.