The Linear Regression Channel Indicator fits a least-squares line through the last 100 bars and wraps it in two bands. Those bands sit a fixed number of residual standard deviations either side. Together they frame the trend and its normal spread. Mean-reversion traders and trend traders both find a use for the picture.
This build ships as linear-regression-channel-indicator-forexmt4systems.ex4 for MT4 and linear-regression-channel-indicator-forexmt4systems.ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 3: LR Mid, LR Upper, LR Lower |
| Alerts | popup, push notification, email, sound |
| Inputs | 9 |
What the Linear Regression Channel Indicator draws on the chart
Three lines land on the price chart. LR Mid runs solid dodger blue through the middle of the fit. A dashed lime-green LR Upper band sits above it. Dashed tomato marks LR Lower below.
Each line recomputes on every bar. The regression window slides forward one bar at a time, so the whole channel drifts with price instead of staying pinned to a start date. The first LRPeriod bars stay blank, since the fit needs a full window.
No other objects appear. The build draws no rectangles, text or panels, so the channel sits cleanly over your candles.
- LR Mid: line, dodger blue, width 2
- LR Upper: line, lime green, width 1
- LR Lower: line, tomato, width 1

How the Linear Regression Channel Indicator calculates its values
Ordinary least squares on the window
The fit uses textbook regression. For each bar the code numbers the window from zero at the oldest to LRPeriod minus one at the newest. It sums the x values, the prices, their products and the squares, then solves for slope and intercept. LR Mid takes the fitted value at the newest position, which is where price sits today.
Bands from residual spread
Width comes from the residuals. The code walks the window a second time, measures the gap between each price and its fitted value, and squares it. The square root of the mean gives a standard deviation for that window. BandStdev defaults to 2.0, so LR Upper and LR Lower land two deviations out.
The alert test
Alerts watch band crossings, not the mid line. On each new bar the code compares the two previous closes against LR Lower and LR Upper. A close that steps up through the lower band fires the buy message. A close that steps down through the upper band fires the sell one.
How to read the signals
Slope carries the trend. A rising LR Mid means the fitted line points up across the whole window, and a falling one means the reverse. Flat means no linear drift over those 100 bars.
The bands frame the normal range. Price inside the channel behaves in line with recent history. A touch of LR Upper says the market sits at the top of its own regression spread. Mean-reversion traders treat that as stretched.
Watch the channel redraw as well. Because the window slides, the whole picture shifts a little each bar. A level that looked like support yesterday may not sit there today.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
EnableAlerts sits in front of popup, push notification, email and sound, each with its own switch. One message goes out per newly closed bar, so a band cross never repeats while the next candle builds.
Every Linear Regression Channel Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
LRPeriod |
Regression period (bars). Sets the regression window at 100 bars; shorter windows hug price and longer ones show the bigger drift. | 100 |
BandStdev |
Band width (stdev multiplier). Multiplies the residual standard deviation to place the two bands, with 2.0 as the shipped width. | 2.0 |
AppliedPrice |
Chooses the price source for the fit and ships as PRICE_CLOSE; median or typical price smooths gappy instruments. | PRICE_CLOSE |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
(see inputs panel) | 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 |

Settings that fit your chart
Regression channels want a market with drift. EURUSD H1, the chart behind the screenshots, holds enough directional legs for a 100 bar fit to mean something. Indices and gold work the same way. On M1 the fit chases noise and the bands squeeze until any move looks extreme. D1 charts give a slow, wide channel that swing traders can hold positions inside.
When the Linear Regression Channel Indicator fails
The channel redraws by design. Every new bar drops the oldest observation and adds a fresh one, so the slope and both bands move. Levels you marked from yesterday’s channel will not match today’s.
A straight line cannot bend. Price that turns inside the window still gets one slope through it, so the channel points the wrong way across the turn.
Band touches are not signals. In a strong trend price can ride LR Upper for dozens of bars while the channel tilts along with it.
The alert only checks the two previous closes. A move that pierces a band inside a bar and pulls back leaves no message at all.
Copy linear-regression-channel-indicator-forexmt4systems.ex4 into MQL4/Indicators and linear-regression-channel-indicator-forexmt4systems.ex5 into MQL5/Indicators, then restart the terminal and drag the Linear Regression Channel Indicator onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Linear Regression Channel Indicator for MT4 and MT5
The zip linear-regression-channel-indicator-forexmt4systems.zip holds linear-regression-channel-indicator-forexmt4systems.ex4, linear-regression-channel-indicator-forexmt4systems.ex5 and a short README, compiled files only. 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.
FAQ
Why does the whole channel move when a new bar prints?
The fit uses a sliding window of LRPeriod bars. Each new candle pushes the oldest one out, which changes the slope, the intercept and the residual spread together. All three lines therefore shift a little every bar. That is normal regression behaviour rather than a fault in the build.
What does BandStdev do to the width of the channel?
It scales the residual standard deviation of the current window. At the shipped setting the bands cover most of the recent spread around the fitted line. Lower it and price touches the edges far more often. Raise it and only the sharpest excursions reach the outer lines.
Which AppliedPrice setting suits a gappy instrument?
The build ships with the close, which most traders keep. On instruments that jump between sessions, median or typical price folds the high and low into the fit and softens those moves. The change affects both the mid line and the band width, since the residuals come from the same source.
How long should LRPeriod be on a EURUSD H1 chart?
One hundred bars covers roughly four trading days on H1, which suits swing reads. Shorter windows follow price closely and produce a channel that turns often. Longer windows describe the bigger picture but react late to a genuine change. Test a few lengths against the swings you already trade.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Linear Regression Channel Indicator as one input. Always backtest before trading live.
Category: this is part of our Trend collection. Also, truly, browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- For background on this concept, see Linear Regression Intercept at StockCharts ChartSchool.
- For broader market context, see Global Financial Centres Index on Wikipedia.
