UDAY_C_Santhakumar

Linear Regression Slope - Version 2

Version 2 - Linear Regression Slope. This version will have more freedom on picking your own length for all the Inputs.

One of the main reason I changed it is because, Slope calculation on transition period was not being computed properly. Because the Version 1, looks back the length assigned, and compute the slope based on two candle readings, could be 10 days apart or 50. That was misleading.

Therefore, I changed it to plot daily slope and Smooth it with an EMA.

Linear Regression Curve -
List of All my Indicators - www.tradingview.com/p/stocks/?sort=recen...

Uday C Santhakumar
Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?
// Created by UCSgears -- Version 2
// Simple linear regression slope - Good way see if the trend is accelarating or decelarating

study(title="UCSGEARS - Linear Regression Slope", shorttitle="UCS-LRS", overlay=false)

src = close
//Input
clen = input (defval = 50, minval = 1, title = "Curve Length")
slen = input(defval=5, minval=1, title="Slope Length")
glen = input(defval=13, minval=1, title="Signal Length")

//Linear Regression Curve
lrc = linreg(src, clen, 0)
//Linear Regression Slope
lrs = (lrc-lrc[1])/1
//Smooth Linear Regression Slope
slrs = ema(lrs, slen)
//Signal Linear Regression Slope
alrs = sma(slrs, glen)
//loalrs = sma(slrs, (glen*5))

uacce = lrs > alrs and lrs > 0 
dacce = lrs < alrs and lrs < 0 

scolor = uacce ? green : dacce ? red : blue

plot(0, title = "Zero Line", color = gray)
plot(slrs, color = scolor, title = "Linear Regression Slope", style = histogram, linewidth = 4)
plot(alrs, color = gray, title = "Average Slope")