# Linear Regression

#### Description <a href="#description_49" id="description_49"></a>

Linear Regression is used to determine trends. Here, the prices are set as dependent variables, and time is set as an independent variable. Using the method for determination of the smallest square, a straight line is placed through the price movements in such a way that the distance between the prices and the line deviates as little as possible. Using this method also establishes a trend between two points in time. The regression line can be found in the middle of the price channel, and the indicator provides the end values of multiple linear regression trend lines. Each point along this indicator is therefore an end value of a linear regression trend line. What results is quite similar to a smoothing average, with the difference that the regression line exhibits less lag.

See [*R-Squared*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#r-squared), [*LinRegSlope*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#linregslope), [*LinRegIntercept*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#linregintercept).

#### Further information <a href="#further-information_20" id="further-information_20"></a>

<http://www.vtad.de/sites/files/forschung/vtad_Award_2011_Joachim_Lenz_Veroeffentlichung.pdf>

#### Interpretation <a href="#interpretation_23" id="interpretation_23"></a>

The linear regression indicator is used as a prognosis tool for the future developments of the instrument. If the prices are rising or falling steadily, then it can be expected that they will return to a more realistic/reasonable level. In other words: the indicator shows where the price should be, a deviation from the regression is assumed to be short-lived and to be corrected soon.

#### Usage <a href="#usage_50" id="usage_50"></a>

```csharp
LinReg(int period)
LinReg(IDataSeries inSeries, int period)
LinReg(int period)[int barsAgo]
LinReg(IDataSeries inSeries, int period)[int barsAgo]
```

#### Return value <a href="#return-value_49" id="return-value_49"></a>

**double**

When using this method with an index (e.g. **LinReg**(14)\[**int** barsAgo] ), the value of the indicator will be issued for the referenced bar.

#### Parameters <a href="#parameters_44" id="parameters_44"></a>

inSeries Input data series for the indicator

period Number of bars included in the calculations

#### Visualization <a href="#visualization_45" id="visualization_45"></a>

![Linear Regression](https://agenatrader.github.io/AgenaIndicator-documentation/media/LinReg.jpg)

#### Example <a href="#example_48" id="example_48"></a>

```csharp
//Show the current values of the regression line
Print("The current value for the linear regression is: " + LinReg(14)[0]);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://indicators.agenatrader.com/standard-indicators/linear-regression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
