This is the code for the SD channel. Can I extract the start and end points of the SD for a defined period? (say 120 periods on 1mn timeframe) A slope will be good enough if I can’t do angle and start and end point would give me that.
/PRC_Std and Ste LinRegChannel | indicator
//Standard Deviation and Standard Error
//Linear Regression Channel
//12.03.2019
//Nicolas @ http://www.prorealcode.com
//Sharing ProRealTime knowledge
defparam drawonlastbaronly=true
defparam calculateonlastbars=1000
// — settings
//lookback= 200 //channel period
//ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
//NbDeviation = 1 //Deviation multiplier
//colorRed = 255
//colorGreen = 255
//colorBlue = 0
// — end of settings
sumx = 0
sumy = 0
sumxy = 0
sumx2 = 0
for cmpt = lookback downto 0 do
tmpx = cmpt
tmpy = close[cmpt]
sumy = sumy+tmpy
sumx = sumx+tmpx
sumx2 = sumx2 + (tmpx*tmpx)
sumxy = sumxy + (tmpy*tmpx)
next
n = lookback+1
if (sumx2 = sumx * sumx) then // protection to avoid infinite values
b = sumxy – sumx * sumy
else
b = (n * sumxy – sumx * sumy) / (n * sumx2 – sumx * sumx)
endif
a = (sumy – b * sumx) / n
drawsegment(barindex[lookback],a[1]+b[1]*lookback,barindex,a[1]+b[1]*0) coloured(colorRed,colorGreen,colorBlue)style(dottedline,1)
//channel
if ChannelType = 1 then //Standard Deviation
dat = std[lookback]*NbDeviation
else
dat = ste[lookback]*NbDeviation
endif
drawsegment(barindex[lookback],(a[1]+b[1]*lookback)+dat[1],barindex,a[1]+b[1]*0+dat[1]) coloured(colorRed,colorGreen,colorBlue)style(line,1)
drawsegment(barindex[lookback],(a[1]+b[1]*lookback)-dat[1],barindex,a[1]+b[1]*0-dat[1]) coloured(colorRed,colorGreen,colorBlue)style(line,1)
return