The linear regression channel cloud indicator fits a straight line through the last hundred closes using ordinary least squares, then places bands either side at a multiple of the fit’s own error. That last detail matters: the bands come from how far price has actually strayed from the line, not from a generic volatility measure bolted on afterwards.
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 | 5: LR Mid, LR Upper, LR Lower, Bull Cloud, Bear Cloud |
| Alerts | popup, push notification, email, sound |
| Inputs | 9 |
What the Linear Regression Channel Cloud Indicator draws on the chart
LR Mid is the gold regression line running through the middle of the window.
LR Upper and LR Lower are the thin dodger blue bands either side of it.
Bull Cloud and Bear Cloud stipple the space between the bands with small dots, spaced by the stride setting.
Nothing appears outside the regression window, since the fit has no meaning beyond it.
- LR Mid: line, gold, width 2
- LR Upper: line, dodger blue, width 1
- LR Lower: line, dodger blue, width 1
- Bull Cloud: arrow, lime, width 1, arrow code 158
- Bear Cloud: arrow, red, width 1, arrow code 158

How the Linear Regression Channel Cloud Indicator calculates its values
Solving the least-squares fit
The code accumulates sumxy and sumxx across the window, then solves for the slope directly. den takes n * sumxx minus sumx squared, b1 takes (n * sumxy – sumx * sumy) / den, and b0 takes (sumy – b1 * sumx) / n. Those are the textbook OLS normal equations, computed exactly rather than approximated.
Measuring the fit’s own error
Each bar’s residual e takes close[i + k] minus fit, where fit is b0 + b1 * x. ssr accumulates the squares, and resid_stdev takes MathSqrt(ssr / n). That number gives the typical distance between price and the line. Feeding it to the bands makes them widen when the fit is poor and tighten when price hugs the trend.
Placing the bands and marking crossings
upper takes val plus `StdDevMult` times sd, with lower subtracting it. The signal test then compares two bars: close[latest+1] at or below UpperBuf[latest+1] while close[latest] clears UpperBuf[latest]. `CloudStride` at `3` spaces the cloud dots so the shading reads as texture rather than a solid block.
How to read the signals
The gold line’s slope is the trend estimate. Flat means the fit found no direction over the window.
Narrow bands mean price has been tracking the line closely, so the fit describes it well.
Wide bands are a warning that the straight-line model is a poor description of what price did.
A close outside a band is unusual by construction, since two standard deviations covers most of the spread.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
Four channels sit beneath `EnableAlerts`: popup, push notification, email and sound, with `SoundFile` naming the clip. Popup ships enabled. The crossing test reads two completed closes, so the message follows a settled bar, one per closed bar.
Every Linear Regression Channel Cloud Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
RegressionLength |
bars in OLS regression window. Bars in the fit window, default `100`. Longer gives a steadier line that reacts slowly to a change of trend. | 100 |
StdDevMult |
band width multiplier (+/- N stdev). Band width in residual standard deviations, default `2.0`. Raise it to 2.5 for rarer band touches. | 2.0 |
CloudStride |
marker stride for cloud shading. Spacing of the cloud dots, default `3`. Raise it to thin the shading on a busy chart. | 3 |
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
A regression channel suits markets that move in reasonably straight legs. EURUSD H1 is the reference chart, where a hundred bars covers about four days. On M5 the window spans a few hours and the line reorients constantly. On H4 and daily the fit describes weeks of structure, which suits swing traders watching for a return to the mean.
When the Linear Regression Channel Cloud Indicator fails
A straight line is a poor model for a market that turns. After a reversal the fit averages both legs and describes neither.
The whole channel repositions as the window rolls forward, so a band that looked significant yesterday may sit elsewhere today.
Residual standard deviation assumes the errors stay roughly normal. Around news they do not, so a band touch means less than the maths implies.
Copy the compiled Linear Regression Channel Cloud 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.
Download the Linear Regression Channel Cloud Indicator for MT4 and MT5
The zip holds the compiled Linear Regression Channel Cloud 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.
FAQ
Why does StdDevMult use residuals instead of ATR?
Because the residuals measure the right thing. resid_stdev is the typical distance between price and this particular fit, so the bands describe how well the straight line explains the data. An ATR band would measure volatility in general, which can be high while price still tracks the trend tightly.
What does RegressionLength at 100 cover?
The hundred closes the least-squares line runs through. On H1 that is roughly four trading days. A longer window steadies the slope and lags a change of direction. A shorter one follows price closely and reorients the whole channel more often.
Does RegressionLength refit the line on every bar?
Yes. The window rolls forward one bar at a time, so the code solves b0 and b1 afresh and the entire channel shifts. That is normal for a rolling regression. It also means today’s line differs from yesterday’s, even over the same stretch of price.
What is CloudStride doing to the display?
Spacing the cloud dots. At `3` the code places a marker every third bar rather than on all of them, so the shading reads as texture instead of a solid fill. Raise it on a busy chart to thin the cloud, or lower it toward 1 for denser shading.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Linear Regression Channel Cloud 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 Fundo de Investimento em Direitos Creditórios on Wikipedia.
