Polynomial Regression Channel
Many indicators calling themselves a "polynomial channel" are a straight line with a curved-sounding name, or a curve approximated by chaining several short linear segments. This one solves an actual least-squares polynomial fit: the normal equations for the chosen degree (2 for a parabola, 3 for an S-curve) are assembled from the window's bar index and closing prices, then solved exactly by Gaussian elimination with partial pivoting - real linear algebra, not a curve-fit approximation. Bar index is centred on the window (x = 0 at the middle bar) purely to keep the matrix well conditioned; raising raw bar indices in the hundreds or thousands to the third power loses precision fast in double arithmetic, and centring keeps every power of x small regardless of window length or how far into history the chart goes. A straight regression line cannot follow a curving trend leg without its edges drifting away from price near both ends of the window - the classic failure mode of forcing a bend into a line. A real polynomial fit tracks that curvature directly. The channel width comes from the standard deviation of the fit's own residuals (actual close minus fitted value) across the window, multiplied by InpDeviations, so the band width reflects how well the polynomial actually explains price in this window rather than an unrelated volatility statistic. Notes and limitations - The entire window is refit on every tick - this is intentional, honest recalculation of history, not a bug. Every value in the channel, including bars well before the current one, can shift as new bars enter the trailing window and old ones leave it. It is not a running series and should not be mistaken for a non-repainting signal line. - A higher-degree fit over a short window can overfit noise rather than capturing genuine curvature - if the line looks like it is chasing individual bars, lower InpDegree or raise InpPeriod. - Purely a visual channel. It draws no arrows and sends no alerts.
Indicator · MT4 · v1.0 · Free
About Polynomial Regression Channel
Polynomial Regression Channel is an indicator for MetaTrader 4. It has 3 settings, such as Period, Degree and Deviations. MQL source code included.
Files in the download: PolynomialRegressionChannel.mq4, PolynomialRegressionChannel.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 100 | Trailing window fitted by the polynomial, in bars |
| Degree | 2 | Polynomial degree - 2 (parabola) or 3 (S-curve) only |
| Deviations | 2.0 | Band offset, in multiples of the fit's residual standard deviation |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Channels & Envelopes · Trailing Stop & Break-even · MT4 Indicator · MQL4 Source Code