DocsMathStatisticsStd Error Bands

Std Error Bands

Windowed · default period 21Statistics

The Standard Error Bands node fits an OLS linear regression to the rolling window and outputs three series: a middle band (the fitted regression value at the latest bar), an upper band (fitted + multiplier × std error), and a lower band (fitted − multiplier × std error). Standard error bands expand when regression fit quality is poor and contract when the trend is clean — unlike Bollinger Bands, they are based on trend linearity rather than absolute deviation.

Algorithm

  • Fit OLS to window pairs (i, v[i]): slope β₁ and intercept β₀
  • fitted = β₀ + β₁ × (period − 1) (value at last bar)
  • SSR = Σ(y − ŷ)² over all non-null pairs
  • stdError = √(SSR / (n − 2)) — requires n ≥ 3 for 2 degrees of freedom
  • upper = fitted + multiplier × stdError
  • middle = fitted
  • lower = fitted − multiplier × stdError

Parameters

NameTypeDefaultDescription
periodnumber21Rolling window size. Minimum 3.
multipliernumber2Std error multiplier for band width.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
uppernumber | nullFitted value + multiplier × std error at each bar
middlenumber | nullOLS fitted (predicted) value at the last bar of the window
lowernumber | nullFitted value − multiplier × std error at each bar
timestampsnumber[]Bar timestamps (UNIX ms), aligned with upper / middle / lower
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

Use Cases

Trend-Relative Channel

Price touching the upper band while the trend is steep and R² is high is a trend-continuation signal. Price returning from outside the band is a mean-reversion entry.

Breakout Filter

Narrow std error bands (small stdError) confirm a clean linear trend. Wide bands warn that the current direction lacks linearity and breakout trades carry higher noise risk.

Dynamic Stop Placement

Use the lower band (in an uptrend) as a dynamic, regression-anchored trailing stop — it tightens as the trend becomes more linear and widens when price becomes erratic.