RicardoSantos

Function Polynomial Regression

RicardoSantos Wizard 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/wik...olynomial_regression
rosettacode.org/wiki...olynomial_regression
Release Notes:
optional colors as input
Release Notes:
added optional degree and use of external library.
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 a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?