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

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

# IIndicatorsAccessor.LinearRegressionSlope

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

## LinearRegressionSlope(DataSeries source, int periods)

The Linear Regression Slope indicator is intended to measure the direction and strength of a trend.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

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

Python:

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

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The price source data used for calculation.
- `periods` (`int`, Python `int`): The period used for calculation.

### Returns

`LinearRegressionSlope` — The Linear Regression Slope indicator instance

### Examples

C#:

```csharp
var slope = Indicators.LinearRegressionSlope(Bars.ClosePrices, 14);
Print("Linear Regression Slope: {0}, trend: {1}", slope.Result.LastValue, slope.Result.LastValue > 0 ? "up" : "down");
```

Python:

```python
slope = api.Indicators.LinearRegressionSlope(api.Bars.ClosePrices, 14)
api.Print(f"Linear Regression Slope: {slope.Result.LastValue}, trend: {'up' if slope.Result.LastValue > 0 else 'down'}")
```

