Quadratic regression

Category: Indicators By: Nicolas Created: August 22, 2018, 9:57 AM
August 22, 2018, 9:57 AM
Indicators
6 Comments

A quadratic regression is the process of finding the equation of the parabola that best fits a set of data. Period of the study can be modified with the “length” setting (default=100).

Converted from a tradingview code.

//PRC_Quadratic Regression | indicator
//22.08.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
length = 100
// --- end of settings 

y = close
x1 = barindex
x2 = square(x1)

S11 = summation[length](x2) - square(summation[length](x1))/length
S12 = summation[length](x1*x2) - (summation[length](x1) * summation[length](x2))/length
S22 = summation[length](square(x2)) - square(summation[length](x2))/length
Sy1 = summation[length](y*x1) - (summation[length](y)*summation[length](x1))/length
Sy2 = summation[length](y*x2) - (summation[length](y)*summation[length](x2))/length

max1 = average[length](x1)
max2 = average[length](x2)
may = average[length](y)
b2 = ((Sy1 * S22) - (Sy2*S12))/(S22*S11 - square(S12))
b3 = ((Sy2 * S11) - (Sy1 * S12))/(S22 * S11 - square(S12))
b1 = may - b2*max1 - b3*max2
qr = b1 + b2*x1 + b3*x2

return qr

 

Download
Filename: PRC_Quadratic-Regression.itf
Downloads: 272
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...