---
id: "M:cAlgo.API.Internals.IIndicatorsAccessor.LinearRegressionForecast(cAlgo.API.DataSeries,System.Int32)"
kind: "method"
type: "T:cAlgo.API.Internals.IIndicatorsAccessor"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/LinearRegressionForecast/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# IIndicatorsAccessor.LinearRegressionForecast

Member of [IIndicatorsAccessor](https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/index.md).

## LinearRegressionForecast(DataSeries source, int periods)

Linear Regression Forecast is a trend indicator used to forecast values using the Least Squares Fit method.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
LinearRegressionForecast LinearRegressionForecast(DataSeries source, int periods)
```

Python:

```python
api.Indicators.LinearRegressionForecast(source: DataSeries, periods: int) -> LinearRegressionForecast
```

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source data used for calculation.
- `periods` (`int`, Python `int`): The value of the periods used for calculation.

### Returns

`LinearRegressionForecast` — Linear Regression Forecast indicator instance

### Examples

C#:

```csharp
var forecast = Indicators.LinearRegressionForecast(Bars.ClosePrices, 14);
Print("Linear Regression Forecast: {0}", forecast.Result.LastValue);
```

Python:

```python
forecast = api.Indicators.LinearRegressionForecast(api.Bars.ClosePrices, 14)
api.Print(f"Linear Regression Forecast: {forecast.Result.LastValue}")
```

