Editors' picks
OPEN-SOURCE SCRIPT

Function Polynomial Regression

Updated
Description:
A function that returns a polynomial regression and deviation information for a data set.

Inputs:
_X: Array containing x data points.
_Y: Array containing y data points.

Outputs:
_predictions: Array with adjusted _Y values.
_max_dev: Max deviation from the mean.
_min_dev: Min deviation from the mean.
_stdev/_sizeX: Average deviation from the mean.

Resources:
en.wikipedia.org/wiki/Polynomial_regression
rosettacode.org/wiki/Polynomial_regression
Release Notes
optional colors as input
Release Notes
added optional degree and use of external library.
experimentalfunctionpolynomialregressionTrend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer