produces the slope (beta), y-intercept (alpha) and coefficient of determination for a
regress(x, y, len ) regress: computes alpha, beta, and r^2 for a of y on x
x: the explaining (independent) variable
y: the dependent variable
len: use the most recent "len" values of x and y
Returns: : alpha is the x-intercept, beta is the slope, an r2 is the coefficient of determination
Note: the chart does not show anything, use the return values to compute model values in your own application, if you wish.
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.
Copy the following line and paste it in your script.