Fit a straight line through the last fifty closes and ask how steep it is. That gradient is the whole output of the linear regression slope indicator. Above zero the fitted line rises, below it falls, and how far from zero tells you how quickly.
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 | Separate window (levels 0) |
| Plots | 3: LR Slope, Up Signal, Down Signal |
| Alerts | popup, push notification, email |
| Inputs | 6 |
What the Linear Regression Slope Indicator draws on the chart
One line and a pair of marks below price.
`LR Slope` runs dodger blue at width 2.
A lime arrow tags a rise through zero.
The red one tags a fall through it.
Zero runs flat across the pane as a reference.
Nothing reaches the price chart itself.
- LR Slope: line, dodger blue, width 2
- Up Signal: arrow, lime, width 2, arrow code 233
- Down Signal: arrow, red, width 2, arrow code 234

How the Linear Regression Slope Indicator calculates its values
Least squares
The maths is textbook. Sums of the bar index, the close, their product and the index squared feed one formula. Out comes the gradient of the best-fit line.
Why the scaling
A slope on a currency pair is minuscule. `SlopeScale` `1000000.0` multiplies it so the line has visible range. The shape stays identical, only the axis changes.
The marks
Zero is the only trigger. A gradient moving from negative to positive prints the up mark. The other direction prints the down one.
How to read the signals
Zero means the fitted line is flat.
Distance from zero is steepness, not price level.
A falling slope above zero means the rise is easing.
`LRPeriod` `50` covers two days on an hourly chart.
The reading is smooth because a fit ignores single bars.
Scaled values only compare within one chart.
Alert channels in this build: popup, push notification and email, one message per closed bar.
`AlertOnCross` handles zero-crossing messages and ships true. `PushOnCross` adds the mobile terminal and `EmailOnCross` adds outgoing mail, both starting off. Crossings report once a bar, and no audio route exists here.
Every Linear Regression Slope Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
LRPeriod |
Linear regression length. Closes the fit runs over, `50`. | 50 |
SlopeScale |
Visibility scaler for tiny FX slopes. Multiplier so the line is visible, `1000000.0`. | 1000000.0 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPx |
Arrow spacing factor. Mark spacing factor, `2`. | 2 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
AlertOnCross |
Alert on zero-cross. Message when the slope crosses zero, `true`. | on |
PushOnCross |
Send push notification. Send that to the mobile terminal, `false`. | off |
EmailOnCross |
Send email. Send it as mail, `false`. | off |

Settings that fit your chart
A fifty-bar fit is slow and steady wherever you put it. EURUSD H1 is the reference chart. Zero crossings come a couple of times a week there. On M5 the slope wanders through zero often. On daily bars it tracks a season.
When the Linear Regression Slope Indicator fails
A fit describes the past fifty bars and nothing else.
The slope keeps rising through a blow-off move.
Scaled height means nothing between symbols.
A zero crossing arrives well after price turned.
Copy the compiled Linear Regression Slope 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 Linear Regression Slope Indicator: Linear Regression R2 at StockCharts ChartSchool, Linear Regression Channel at BabyPips.
Download the Linear Regression Slope Indicator for MT4 and MT5
The zip holds the compiled Linear Regression Slope 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
What exactly does the LR Slope plot show?
The gradient of a least-squares line fitted through the last fifty closes. It answers how steeply price has been rising or falling, which is a different question from where price currently sits.
Why does SlopeScale multiply by a million?
Because a gradient on a five-digit currency quote is a fraction of a pip per bar. Unscaled the line would sit flat against zero, so every value gets the same multiplier to give it visible range.
What does a falling slope above zero mean?
That price is still rising but doing so more slowly than before. The fit stays positive while its steepness decreases, which often shows up before the slope actually crosses under zero.
Is LRPeriod 50 the right length?
It is a middle choice. Fifty closes smooths out single bars entirely, which makes the line steady but slow. Shortening it produces a livelier slope with far more zero crossings to sift through.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Linear Regression Slope 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
- The core method is documented in Linear Regression R2 at StockCharts ChartSchool.
- Additional market context is at GreenSky on Wikipedia.
