Polynomial Regression Channel Indicator MT4 + MT5

Written by Dominic Walsh · Published · Last updated

The polynomial regression channel indicator draws a straight fair-value line over the last Period closes. It redraws that line on every bar. The name says polynomial, but this build fits a single first-degree line, not a curved multi-degree shape. It has no upper or lower band next to the line. Traders use it as a fast fair-value read, not a fixed moving average.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 1: Polynomial
Alerts popup, push notification, email, sound
Inputs 7

What the Polynomial Regression Channel Indicator draws on the chart

Polynomial is the one plotted line: a sea-green trace holding the regression value for each bar.

No second buffer sits above or below it, so the chart shows a single line, not a shaded channel.

  • Polynomial: plot, sea green
Polynomial regression channel indicator line on an EURUSD H1 chart.
Polynomial regression channel indicator line on an EURUSD H1 chart.

How the Polynomial Regression Channel Indicator calculates its values

Least-squares fit over Period bars

For each bar the code sums x, y, xy and x-squared across the Period window of closes. It then solves the standard least-squares formula for slope and intercept.

The code writes only the intercept into the Polynomial buffer. It sums no quadratic or cubic term. That makes this a straight-line fit, not a higher-degree curve, and it adds no offset band around the line.

Crossover check

On the last two closed bars the code compares the close price against the regression value. It checks the prior bar first, then the current bar.

That comparison decides whether price crossed above or below the line. Once it fires, the code sends the matching alert through EnableAlerts and its four channel toggles.

Why the line moves the way it does

Because the fit runs fresh on every bar, the whole line can shift, not just its rightmost point. A single large bar inside the Period window can tilt the slope for the entire visible line.

This differs from a simple moving average, which only adds one new bar and drops one old bar. The regression line reacts to the shape of the whole window, so it can bend faster after a sharp move.

How to read the signals

Price crossing above the sea-green line from below is the bullish signal in this code.

Price crossing below it from above is the bearish signal.

The line’s slope shows the trend the fit sees over the Period window: flat means no clear direction, steep means a strong recent move.

The build draws no shaded channel; only the single regression line appears on the chart.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Alerts cover popup, push, email and sound, and fire once per closed bar.

Every Polynomial Regression Channel Indicator input

Core settings

Setting What it does Default
Period Number of closes feeding the least-squares fit; default `50`. A shorter Period tracks price more closely and crosses more often. A longer Period smooths the line and cuts down on false crosses in a choppy market. 50

Alert settings

Setting What it does Default
EnableAlerts Master switch for all four alert channels; on by default. Turn it off to watch the line without notifications. on
EnablePopup (see inputs panel) on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile (see inputs panel) alert.wav
Inputs panel for the polynomial regression channel indicator, Period and alert toggles.
Inputs panel for the polynomial regression channel indicator, Period and alert toggles.

Settings that fit your chart

A regression line like this reacts to whatever timeframe you attach it to; the screenshot below uses EURUSD H1 with the default Period.

When the Polynomial Regression Channel Indicator fails

It fits a straight line. A real curved swing pulls the line through the middle of the move instead of tracking the curve, unlike a true higher-degree polynomial fit.

This build has no channel band, so do not expect an upper or lower boundary just because the product name says channel.

In a tight range the line sits close to price, and small, low-conviction wiggles can trigger the crossover alert.

Because the whole line redraws each bar, a value that looked confirmed one bar back can shift slightly on the next bar as new price data enters the fit.

Copy the compiled Polynomial Regression Channel Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Background reading on the method behind the Polynomial Regression Channel Indicator: Linear Regression R2 at StockCharts ChartSchool, Journal of Behavioral Finance on Wikipedia.

Download the Polynomial Regression Channel Indicator for MT4 and MT5

The zip holds the compiled Polynomial Regression Channel Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Is this actually a higher-degree polynomial fit?

No. The code sums only first-degree terms, x, y, xy and x-squared, and solves for one slope and one intercept. That is a straight least-squares line, not a curved multi-degree polynomial, despite the product name.

Does this build draw a channel with upper and lower bands?

No. The source declares one buffer, Polynomial, and plots only that line. There is no second buffer offset above or below it, so no channel appears on the chart.

What happens if I shorten the Period on this regression line?

A shorter Period makes the line track recent closes more closely and cross price more often. A longer Period smooths the line into a slower read that reacts less to short swings.

Does EnableAlerts control the crossover signal itself?

No. EnableAlerts and its four channel toggles only control whether the code notifies you when a crossover happens. The crossover condition comes from comparing the close against the regression value on the last two closed bars.

Why does the whole line move, not just the newest bar?

Because the fit reruns over the full Period window on every bar, one large bar entering or leaving that window can tilt the slope across the whole visible line, not just the latest point.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Polynomial Regression Channel Indicator as one input. Always backtest before trading live.

Category: this is part of our Trend collection. Browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment