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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
//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 |

### Share this

**Risk disclosure:**

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

**ProRealTime ITF files and other attachments :**

**Filename :**download the ITF files

*How to import ITF files into ProRealTime platform?*

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

murri• 08/22/2018 #Muy interesante. Solo que a mi me aparece no sobre el precio sino en pantalla aparte. ¿Cómo hacerlo para que se sobre imprese con la pantalla del precio? Gracias

Nicolas• 08/22/2018 #Agréguelo a la tabla de precios usando el botón de configuración de precios en la tabla.

Traderfox06• 08/22/2018 #Dear Nicolas,

I believe in the high potential of quadratic regression for an automated system.

Therefore, I would like to understand in detail the principles how you have coded the algo.

All the mathematical derivations I found, look somehow different, e.g. this one:

https://www.azdhs.gov/documents/preparedness/state-laboratory/lab-licensure-certification/technical-resources/calibration-training/12-quadratic-least-squares-regression-calib.pdf

Could you give me some more detailed information, please?

Another question:

Does this summation command:

S11 = summation[length](x2) – square(summation[length](x1))/length,

mean, that this line is like a loop which is processed times every 5 minutes if the period is M5?

Thanks and kind regards,

Michael

Nicolas• 08/22/2018 #S11 variable is not a loop but a ratio calculation. In real time the codes is processed on each new tick received. On history, it is calculated with the Close of each candlestick, same goes for all indicators, not only with this one.

Stephan_V• 08/22/2018 #Nicolas,

This regression delivers damn good results, especially for trends !

I’m wondering what degree of Polynomial Regression is used, and frankly, I can’t recognize any polynomial resolution from your code.

Do you have any background and formula that helped you in building that piece ?

Thanks,

Et toutes mes félicitations pour ce site que tu gères de main de maître ! Ca doit représenter du temps et bcp d’expertise …

Saches que ça aide beaucoup de monde, à commencer par moi-même.

Stephan

Nicolas• 08/22/2018 #Least square method is used here in order to get the perfect y = ax2 + bx + c