IIndicatorsAccessor.LinearRegressionSlope
method · IIndicatorsAccessor · cAlgo.API.Internals
DesktopCLICloud
The Linear Regression Slope indicator is intended to measure the direction and strength of a trend.
Definition
LinearRegressionSlope LinearRegressionSlope(DataSeries source, int periods)
api.Indicators.LinearRegressionSlope(source: DataSeries, periods: int) -> LinearRegressionSlope
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
source | DataSeries | DataSeries | The price source data used for calculation. |
periods | int | int | The period used for calculation. |
Returns LinearRegressionSlope — The Linear Regression Slope indicator instance
Examples
var slope = Indicators.LinearRegressionSlope(Bars.ClosePrices, 14);
Print("Linear Regression Slope: {0}, trend: {1}", slope.Result.LastValue, slope.Result.LastValue > 0 ? "up" : "down");
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'}")