# Linear Reg Line

The Linear Regression Line is a straight line that best fits the price data, showing the general direction of a trend by minimizing the distance between the line and actual prices over a specified period.

## Definition

Linear regression analyzes two separate variables in order to define a single relationship. In chart analysis, this refers to the variables of price and time. Investors and traders who use charts recognize the ups and downs of price printed horizontally from day-to-day, minute-to-minute, or week-to-week, depending on the evaluated time frame. The different market approaches are what make linear regression analysis so attractive. Basically, linear regression is the analysis of two separate variables to define a single relationship and is a useful measure for technical and quantitative analysis in financial markets.

The Linear Regression Line is commonly used to predict future market values relative to their past values and is plotted on a price chart as a straight line, similar to a trendline. This indicator helps to determine where a market's price might be in the near future using current and past price history. If prices are trending up, linear regression attempts to logically determine the upward bias of the price that may be relative to the current price. If prices are trending down, it will attempt to determine the downward bias of the price. Some analysts believe that when prices rise above or fall below the linear regression line, they are overextended and will begin to move back towards the line. Thus, the line is used to monitor when a price move may change direction.

This indicator does not plot a line or histogram, rather, it plots a trendline displayed in the same subchart as the main data series.

## Default Inputs

**Length( 30 )** sets the number of bars used for calculation.

**EndDate_YYMMDD( 0 )** (optional) sets the date of a bar (in YYYMMDD format) for the endpoint. If set to 0, the endpoint is the last bar at the time the indicator is applied.

**EndTime_HHMMSS( 0 )** sets the time (in 24 hour HHMMSS format) for the endpoint. If set to 0, the time is ignored.

**Color( yellow )** sets the trendline color.

**ExtRight( true )** determines whether to extend the linear regression line to the right of the EndDate/EndTime bar (true) or stop at the bar (false).