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]
// usage IEnumerable<SlopeResult> results = quotes.GetSlope(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.
- This method returns a time series of all available indicator values for the
- It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
N-1periods will have
Slopesince there’s not enough data to calculate.
Linevalues are only provided for the last
Nperiods of your quote history
Repaint warning: the
Linewill be continuously repainted since it is based on the last quote and lookback period.
DateTime - Date from evaluated
double - Slope
m of the best-fit line of price
double - Y-Intercept
b of the best-fit line
double - Standard Deviation of price over
N lookback periods
double - R-Squared (R²), aka Coefficient of Determination
decimal - Best-fit line
y over the last
N periods (i.e.
y=mx+b using last period values)
See Utilities and helpers for more information.
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(..);