Home > Net >  What's the logic within LINREG function in pine (trading view)?
What's the logic within LINREG function in pine (trading view)?

Time:11-26

So i'm building some sort of charts in C#, i'm basically reverse-engineering what I need from TradingView functions which uses PineScript.

I'm Kind of stuck with this one "LINREG" because there is no deep explanation on what's being calculated whitin the function: https://www.tradingview.com/pine-script-reference/v1/#fun_linreg

interface: linreg(source, length, offset) → series

formula: linreg = intercept slope * (length - 1 - offset)

  • where length: is the y argument
  • offset is the z argument
  • "intercept and slope are the values calculated with the least squares method on source series (x argument)" <-- This third bullet is a total mistery

Does somebody has the logic behind this 3rd bullet?, not necessary in C# code, to understand the logic will be enought for me.

Thanks in advance.

CodePudding user response:

LINREG short for linear regression, a statistical tool you may know about already.

This website will help you with understanding the formula-

https://budgeting.thenest.com/calculate-linear-regression-lines-slopes-stock-prices-33550.html

CodePudding user response:

x argument is the source series.

There is modern reference man: https://www.tradingview.com/pine-script-reference/v5/#fun_ta{dot}linreg

  • Related