Skip to content
All library documents

Using Linear Regression Slope as a Trend and Consolidation Oscillator

Article MQL5 code base

Summary

TrendLinearReg fits a straight line to a rolling window of prices and plots the regression slope as a non-normalized histogram. The slope coefficient represents the direction and steepness of the fitted line. Histogram color tracks whether that coefficient has increased or decreased from the previous bar, so color change describes a change in slope rather than simply whether the slope is positive or negative.

The document suggests reading zero-line crossings as possible trend changes, treating extreme readings as a potential signal, or defining a band around zero as a consolidation zone and watching for breaks from it. It gives no tests, thresholds, or trading results, and it warns that the slope scale varies across instruments because it depends on both the line’s angle and the scale of the price series. The proposed uses are therefore ideas to calibrate and validate per instrument, not a fully specified trading system.

Key ideas

  • The indicator calculates a rolling linear regression slope and displays it as a histogram.
  • Histogram colors show whether the slope is rising or falling relative to its prior reading.
  • A zero-line crossing can be interpreted as a possible change in trend.
  • An extreme slope reading or a break from a defined band around zero may also be used as a signal.
  • Because the measure is not normalized, its scale can differ across instruments.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.