STE
STE in ProBuilder returns the standard error of a price series over N bars, measuring how far prices stray from the regression line. Syntax and examples.
Syntax
STE[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 20 | Number of bars used to fit the regression line and measure the residuals. |
price | price source | close | The series fitted by the regression. Accepts close, open, high, low, or a custom variable. |
Formula
STE is the square root of the averaged squared residuals between each of the last N prices and the straight line fitted through them by least squares:
STE = SQRT( average of (price - RegressionLine)^2 over N bars )It is the regression-line counterpart of STD, which measures the same kind of dispersion around a moving average instead of around a fitted line.
How it works
On every bar, ProBuilder fits a least-squares straight line through the last N values of price, the same line returned by LinearRegression. STE then measures how far, on average, the actual prices sit from that line. The result is expressed in price units.
The distinction from standard deviation matters in trends. A market rising steadily in a straight line has a large deviation from its own average (the average lags behind), but a very small deviation from its regression line. STE therefore isolates noise around the trend rather than the trend itself, which makes it a measure of trend quality: how faithfully price is tracking its own trajectory.
STE is commonly read together with R2, the coefficient of determination for the same regression. A high R2 with a low STE describes a strong, reliable trend. When the two series converge from opposite directions, R2 falling while STE rises, the fit is degrading, which often accompanies the transition into consolidation or reversal.
Examples
Example 1, Plotting the regression error (Indicator)
myseries = close
// Typical distance between the close and its 10-bar regression line
statisticalerror = STE[10](myseries)
RETURN statisticalerrorCalculates the standard error of the close over the last 10 bars and plots it. Falling values mean price is hugging its trend line more tightly.
Example 2, Trend quality filter (ProOrder)
// Trade momentum only when the trend fit is clean
fitError = STE[20](close)
fitR2 = R2[20](close)
slope = LinearRegressionSlope[20](close)
IF NOT OnMarket THEN
// High R2, contracting error, rising slope
IF fitR2 > 0.8 AND fitError < Average[50](fitError) AND slope > 0 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
ELSIF fitR2 < 0.5 THEN
SELL AT MARKET
ENDIFEnters long only when the 20-bar regression fit is strong (high R2, below-average STE, positive slope) and exits when the fit deteriorates.
Example 3, Screening for orderly trends (ProScreener)
// Instruments trending cleanly: small error relative to price
err = STE[20](close)
relError = (err / close) * 100
up = LinearRegressionSlope[20](close) > 0
SCREENER[up AND relError < 1](relError AS "STE % of price")Returns instruments in a rising 20-bar regression whose standard error is under 1 percent of price, i.e. tight, low-noise uptrends.
Interpretation
- Low and falling STE. Price is tracking its regression line closely. The trend, whatever its direction, is orderly and the line is a meaningful reference.
- High or rising STE. Price is oscillating widely around the fit. Trend-following signals derived from the regression are less dependable.
- STE with R2. The pair works as a quality gauge: R2 says how much of the movement the line explains, STE says how large the unexplained part is in price terms. Convergence of the two from opposite directions frequently marks a regime change.
STE carries no directional information. Combine it with LinearRegressionSlope or a moving-average condition to define direction.
Common errors and gotchas
- Confusing STE with STD. In a steady trend STD stays elevated while STE collapses, because the regression line follows the trend and the moving average does not. Substituting one for the other silently changes the meaning of a filter.
- Comparing absolute values across instruments. STE is in price units. Screen or rank on
STE / closerather than the raw value. - Short windows overfit. With small
N, the regression line passes almost through every point and STE approaches zero without indicating a genuinely clean trend. Windows of 20 or more bars give more meaningful readings. - Reading STE alone. A low error around a flat line describes a quiet range, not a trend. Check the slope or R2 before treating low STE as trend confirmation.
Related instructions
STD, standard deviation around a moving average.R2, coefficient of determination of the same regression fit.LinearRegression, the fitted regression line value itself.LinearRegressionSlope, direction and steepness of the regression line.Average, simple moving average, the reference used by STD.Volatility, general volatility estimate for comparison.
