Slope and Linear Regression

Slope of the best fit line is determined by an ordinary least-squares simple linear regression on price. It can be used to help identify trend strength and direction. [Discuss] :speech_balloon:

image image

// usage
IEnumerable<SlopeResult> results =
  quotes.GetSlope(lookbackPeriods);

Parameters

lookbackPeriods int - Number of periods (N) for the linear regression. Must be greater than 1.

Historical quotes requirements

You must have at least N periods of quotes to cover the warmup periods.

quotes is a collection of generic TQuote historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

Response

IEnumerable<SlopeResult>

:paintbrush: Repaint warning: the Line will be continuously repainted since it is based on the last quote and lookback period.

SlopeResult

Date DateTime - Date from evaluated TQuote

Slope double - Slope m of the best-fit line of price

Intercept double - Y-Intercept b of the best-fit line

StdDev double - Standard Deviation of price over N lookback periods

RSquared double - R-Squared (R²), aka Coefficient of Determination

Line decimal - Best-fit line y over the last N periods (i.e. y=mx+b using last period values)

Utilities

See Utilities and helpers for more information.

Chaining

This indicator may be generated from any chain-enabled indicator or method.

// example
var results = quotes
    .GetEma(..)
    .GetSlope(..);

Results can be further processed on Slope with additional chain-enabled indicators.

// example
var results = quotes
    .GetSlope(..)
    .GetRsi(..);