How it works
Standard Error Bands replace the moving average at the centre of a normal envelope with a linear regression line, and replace the standard deviation of price with the standard error of that regression. The change of reference matters. A moving average is a horizontal-ish estimate that lags a trending market badly; a regression line has a slope, so in a steady trend it sits right in the middle of price rather than trailing behind it. The bands then measure how tightly price is clustering around that sloped fit.
This produces a behaviour that is the opposite of what a Bollinger user expects, and it is the whole point of the tool. In a strong, orderly trend, price hugs the regression line closely, the standard error is small, and the bands contract. When the trend breaks down and price scatters, the fit gets worse, the standard error rises, and the bands widen. Narrow Standard Error Bands therefore mean a trend that is holding together, while widening bands mean the trend is losing coherence. Bollinger Bands, which measure raw dispersion rather than dispersion around a fitted slope, do the reverse.
The practical reading follows directly. Traders watch for the bands to contract as confirmation that a trend is well formed, and treat a sustained widening after a contraction as a warning that the structure is deteriorating. The slope of the centre line is the trend direction itself, and its flattening after a run is an independent signal. Because the endpoint of a regression line moves as each new bar arrives, most implementations smooth both the centre and the bands with a short simple average, typically three periods, to keep the plot readable.
Compared with a linear regression channel, which fixes its width to the maximum deviation or a chosen number of deviations over a fixed anchored window, Standard Error Bands are rolling and their width has a statistical meaning: the standard error is the typical size of the residual between price and the fit. That makes them a measure of trend quality rather than of price extremes, which is a distinct and genuinely useful thing to have on a chart alongside a conventional envelope.
Calculation
The arithmetic in words, in the order it happens.
Over a rolling window of N bars, conventionally 21, fit a least-squares straight line to price against bar number. The centre line is the value of that fitted line at the most recent bar, the regression endpoint. Compute the residuals, the differences between each actual price and the fitted line, and calculate the standard error as the square root of the sum of squared residuals divided by N minus 2. The upper band is the centre plus 2 standard errors and the lower band is the centre minus 2. Most implementations then apply a 3-period simple moving average to the centre and to both bands to smooth the jitter that comes from refitting the line on every bar.
Source
An AlgoBeamScript implementation of the formula above, written by us from the arithmetic so the code and the calculation agree line for line.
Runs unchanged on the platform and in the AlgoBeamTS runtime. The language reference is in the documentation.
Inputs
Defaults are the values most charting packages ship with. They are conventions, not optimal settings — the right length depends on your instrument and your holding period.
| Input | Default | What it changes |
|---|---|---|
| Regression length | 21 | Bars used for the least-squares fit. Short windows follow every swing and their bands stay narrow; long windows describe a larger structural trend and widen whenever price deviates from it. |
| Standard errors | 2 | Half-width of the bands in standard-error units. Two is conventional. Smaller values make the bands hug the fit and turn every wobble into a band break. |
| Smoothing | 3 | Simple average applied to the centre and bands after computation. Raising it produces a cleaner plot at the cost of delaying the moment a widening becomes visible. |
| Source | Close | Series the line is fitted to. Typical price gives a slightly more stable fit on instruments with noisy closes, at the cost of departing from the standard definition. |
How to read it
What practitioners take from the plot. Read these as descriptions of market state, not as entry signals.
- Bands contracting
- Price is tracking a straight line closely. The trend is coherent, which is the opposite of what contraction means on a Bollinger envelope.
- Bands widening after a contraction
- Residuals are growing and the linear fit is deteriorating. The trend is losing structure even if price has not yet turned.
- Centre line slope flattening
- The fitted trend has run out of gradient. Often the earliest objective sign that a directional phase is ending.
- Price outside a narrow band
- A move well beyond what the current fit explains. In a tight trend this is a genuine anomaly rather than a routine excursion.
Limitations
Where this indicator misleads. None of these are fixed by a better parameter.
- The regression endpoint is refit on every bar, so the centre line can repaint visually as the window rolls forward and the historical plot does not show what a trader would have seen live.
- A straight line is a poor description of a market that is turning, and around every major reversal the fit is at its worst precisely when a clear read matters most.
- The inverted interpretation of width trips up almost everyone who arrives from Bollinger Bands, and mixing the two conventions on one chart is a reliable way to misread both.
- Like every window-based tool it lags, and the length chosen determines which trend it describes, so a well-behaved reading on 21 bars can coexist with total chaos on 100.
Educational reference. This page explains how an indicator is built and how it is commonly read. It is not investment advice, not a recommendation and not a signal service. No indicator is profitable on its own — each is a way of describing a market, and any rule built on one has to be tested with realistic costs before it is traded.