Moving Linear Regression (MLR)

Moving Linear Regression, also known as the End Point Moving Average, begins by fitting an unseen line to a set of data points. These points are specified by the Price and Period parameters. The process of fitting the line to the data points uses the least squares technique. This technique finds the line that minimizes the sum of the squares of the distances between each point and the line.

The value of the fitted line at the last point (end point of the line) for the specified period is plotted on the chart. The set of data points then shifts to the next most recent bar and another line is fitted to these points. The end point of this line and of successive lines is plotted on the chart. The displayed Moving Linear Regression line connects these calculated end points. An envelope can be displayed in relation to the Moving Linear Regression line by setting selecting percent, factor x standard error, or factor x residuals as the envelope type.

The beauty of this study compared to most momentum-based, trend-following indicators is the fact that it tracks the trend however steep or shallow. In short, it maintains sensitivity without causing time lag. The other main difference is that in order to signal the end of a trend, the line must simply change direction. It does not signal the end of a trend if price crosses the line.

The study can be applied to any market and any timeframe with variables normally set anywhere between 20 and 80 periods. The higher number is for use on high frequency short term trading methods often associated with CQG’s TFlow.

It is possible to place bands around the line. The best setting to use is the factor and standard error with a factor set at 2 or 3. It’s also important so that you have a fixed reference on an extreme that the offset is either set at 1 or the calculation goes through the open instead of the close. This means that an extreme value is set for the timeframe chart and represents partial profit taking points to trend following trades or aggressive counter trend trades, if linked to other extreme reading studies such as Volatility Time Bands or Range Deviation Pivots. The chart below shows an example where a breakout is signaled by a close beyond the lower regression and the 3rd deviation of the Volatility Time Band. As the trend develops the extreme low is exactly at the Regression Band low which coincides with the Volatility Time Band low. This means that the market is at an extreme on both an absolute momentum basis( regression band) and at an extreme for the time of day (Volatility Time Band). This also provides a counter trend opportunity.

Moving Linear Regression Outputs

Parameter

Description

MLRTE(21)

Moving Linear Regression Top Envelope (21-period).

MLRBE(21)

Moving Linear Regression Bottom Envelope (21-period).

MLRIntercept(21)

Moving Linear Regression Intercept.

MLR(21)

Moving Linear Regression Line.

MLRSlope(21)

Slope of the Moving Linear Regression Line.

MLRResidual(21)

The total amount the observations deviate from the mean.

MLRRSquared(21)

The correlation coefficient, indicating how well the observed data points fit the linear regression line.

MLRTEE(21)

Moving Linear Regression Top Envelope, Standard Error

MLR(@,period) + Factor * StdDev(@,period)

MLRBEE(21)

Moving Linear Regression Bottom Envelope, Standard Error

MLR(@,period) + Factor * StdDev(@,period)

MLRTRE(21)

Moving Linear Regression Top Envelope, Residual

MLR(@,period) + Factor * SqRoot(MLRResidual(@,period)/(period-1)) with n-1 as divisor

MLRBRE(21)

Moving Linear Regression Bottom Envelope, Residual

MLR(@,period) + Factor * SqRoot(MLRResidual(@,period)/(period-1)) with n-1 as divisor

Moving Linear Regression Parameters

Parameter

Description

Display

Opens sub-window to set parameters

      Color = Line color.

      Weight = Line thickness.

      Display = Line style: line or histogram.

      ShareScale = Determines whether sharing of the vertical scales between studies is accepted. Auto = System determine whether sharing is feasible. On = Scale is shared regardless of the functions and studies displayed. Off = Scale is not shared. ShareScale must be On if study is overlaid on a study with multiple outputs.

MarkIt

Opens Specify Conditions window.

Offset

Distance in bars between the current bar and the bar to use in the calculation. A positive offset uses future bars. A negative offset uses past bars. For example:

1 = next bar

-2 = two bars back from current bar

Period

Number of bars in the lookback range.

Price

Price used to calculate study values.

Envelope

Method used for determining the location of an envelope in relation to the MLR line. Values:

      Percent

      Factor x Std Err = MLR(@,period) + Factor * StdDev(@,period)

      Factor x Residuals = MLR(@,period) + Factor * SqRoot(MLRResidual(@,period)/(period-1))with n-1 as divisor

Percent

Percent added to and subtracted from regression line to form top and bottom envelopes, if Percent was chosen as the Envelope parameter.

Factor

Positive or negative factor used in factor-based envelope calculation. Used with Envelope and Divisor parameters.

Divisor

Values:

      N = standard deviation

      N-1 = population standard deviation (estimate of population based on sample)

 

In addition to these parameters, the Formula Toolbox can be used to access additional Moving Linear Regression parameters that can be used in custom studies.