Polynomial Regression Bands
Rolling second-degree (or linear) regression of the close with bands at a multiple of the residual standard deviation, plus slope and bend values.
What you see
Three lines on the price chart: the regression line (Line Color), a translucent green upper band and a translucent red lower band. Each point comes from its own fit over the candles up to that point, so later candles do not redraw earlier values. With Show Window Curves on, ChartRider also draws the complete fitted curve and its bands across the window of the candle under the crosshair, and puts a dot on the most recent candle in that window whose high was above, or whose low was below, the curve's band.
How it is calculated
For every candle, with N = Regression Period and k = Band width:
- Fit
y = a·x² + b·x + cby least squares to the last N closes at x = 0 to N − 1; withLinear Regressionon, fity = b·x + c. regressionis the fitted curve at the newest candle (x = N − 1).σ = √(sum of (close − fit)² / N), the spread of the closes around the curve.upper = regression + k × σandlower = regression − k × σ.slopeis the change of the curve across the window relative to its newest value:(newest − oldest) / newest.bendis the curvature from 0 to 1:|a| × (N − 1)²divided by the price range of the curve, compressed withx / (x + 0.15). 0 is a straight line (always with linear regression), values near 1 a strongly arched curve.
With Time Frame Multiplier above 1, the candles are first combined into a higher timeframe (chart timeframe × multiplier, aligned to UTC).
How to read it
- The regression line is a smoothed trend estimate that bends with price, unlike a straight regression channel.
- Closes outside the bands are stretched relative to the window's trend: candidates for mean reversion in ranges, or signs of acceleration in breakouts.
- A rising
bendwhileslopeflattens hints that the curve is turning.
Using it in strategies
Outputs: regression, upper, lower, slope and bend. In the Trade Setup, "Compare" a band with the price, e.g. lower above the price for a close below the lower band; "Price vs line" on regression is a trend filter. With a multiplier, a value only counts once its higher-timeframe candle has closed. WickScript has no built-in function for it; use use indicator "PolyReg" with period 150, periodBand 2 as pr and read pr.upper, pr.lower and the other outputs.
Settings
Open the settings with the slider icon next to the indicator (Indicators, F3). Numeric settings can be swept as Step 1 / Step 2 parameters when you run a strategy.
Inputs
| Setting | Type | Default | Description |
|---|---|---|---|
| Regression Period | Number | 150 | Number of closes per fit (N, at least 3). (min 3) |
| Linear Regression | On/off | off | Fit a straight line instead of a parabola. |
| Show Window Curves | On/off | off | Draw the full fitted curve with its bands for the candle under the crosshair, plus dots at the latest band breaks inside that window. |
| Band width (std multiplier) | Number | 2 | Distance of the bands in standard deviations (k). 0 puts both bands on the regression line. (min 0) |
| Time Frame Multiplier) | Number | 1 | Calculate on a higher timeframe: chart timeframe × this whole number. (min 1) |
Styles
| Setting | Type | Default | Description |
|---|---|---|---|
| Line Color | Color | #1A4C93 |
Outputs
These values can be used in Trade Setup triggers, filters and exits (see Trade Setup) and in WickScript.
| Output | In WickScript | Description |
|---|---|---|
| regression | regression | End point of the fitted curve (a price). |
| upper | upper | Regression plus k standard deviations. |
| lower | lower | Regression minus k standard deviations. |
| slope | slope | Change of the fitted curve across the window, relative to its newest value. |
| bend | bend | Curvature of the fitted curve, from 0 (straight) to 1 (strongly arched). |
Use in WickScript
use indicator creates this indicator inside a script, with settings by their ID. Each output is a field of the name after as. See WickScript indicators.
wickscript 1
indicator "Polynomial Regression Bands from the list" on chart
use indicator "PolyReg" with period 150 as myPolyreg
show myPolyreg.regression as line "regression"