In this article, we will review the Linear Regression indicator, which displays the best-fit line through the last N bars based on their prices, such as close, high, or low.
The Linear Regression indicator shows the linear regression of the last N bars, as a best-fit line through their close prices (or highs, or lows etc). You can add multiple copies of the indicator to a chart in order to show different regressions: for example, one indicator showing the linear regression of the highs and another showing the linear regression of the lows, forming a channel.
You can also use the indicator to show the regression of prices on another timeframe, e.g. the linear regression of D1 close prices while viewing an H1 chart.
How to install Linear Regression Indicator?
To download and install the Pro Trading Tools please follow these steps:
- Login to MyFXTM dashboard > Trading Signals > Pro Trading Tools
- Download FX Blue or Trading Central for your Platform (Meta Trader 4 or Meta Trader 5)
- Run the dowloaded FX Blue and Trading Central files and apply them to your chosen MetaTrader Platform when prompted.
- Relaunch the MetaTrader platform. You’ll find your FX Blue* and Trading Central tools in the ‘Navigator panel under ‘Indicators’ and/or ‘Expert Advisors’.
Using the Linear Regression indicator
Adding the indicator to a chart
You add the Linear Regression indicator to a chart in the usual MT4 way, either by dragging it from the Navigator onto a chart, or by double-clicking on it in the Navigator. You can also use standard MT4 features such as adding the indicator to your list of Favorites, or assigning a Hotkey to it.
Choosing the number of bars, and the shift
You use the Inputs tab to tell the indicator how many bars to include in the calculation (a minimum of 2).
You can also set the bar-shift. The default value of 1 means “up to, but not including, the current bar”. A value of 0 would include the current bar, and the regression calculation would therefore change slightly on each tick.
Extending the line to the current bar
By default the indicator will extend the regression line to the current bar. For example, with a bar-shift of 1 the calculation will not include the current bar, but the indicator will extend the drawing of the line into the current bar for comparative purposes. You can turn off this extension using the Inputs tab (and the setting is irrelevant if the bar-shift is zero).
Price type
You can use the Inputs tab to calculate the linear regression of different types of price: not just the close price, but also the high, low, open, median, typical, or weighted price.
You can add multiple copies of the indicator to a chart in order to show different regressions: for example, one indicator showing the linear regression of the highs and another showing the linear regression of the lows, forming a channel.
Timeframe
By default the indicator will use the timeframe of the current chart, and will change its calculation if you change the chart. However, you can use the Inputs tab to specify a different timeframe, e.g. showing the regression of D1 prices while viewing an H1 chart.
Interpolation on higher timeframes
When showing the regression from a higher timeframe on a lower timeframe chart (e.g. D1 versus H1), by default the indicator will show the same single value for each bar which makes up the higher timeframe. This creates a stepped line such as the following:
You can use the Inputs tab to tell the indicator instead to interpolate values for each individual bar on the lower timeframe, creating a smoothed line.
However, please note that the interpolation can create a “kink” in the line at the beginning of the current period. For example, if you are viewing the D1 regression on an H1 chart, and the current day is only 3 H1 bars old, then the values for the current day are interpolated over only 3 bars whereas the values for all previous, full days are interpolated over 24 hourly bars. This creates the “kink”.
Colours and line styles
You can set the colour and style for the indicator’s line in the usual way, via the Colors tab.