This is my final version. I made some changes because I saw that volatility changes affect both the compressions and the expansions.
So the inidator treats supports and resistance on the expansion returns, in the same way supports and resistance on the beginning of volatility expansion.
It would be nice to be able to put the names to the supports and resistors, example above or to finaco to the line S1, S2, R1, R2 etc. but I do not know how to do it 🙂
//https://www.prorealcode.com/topic/volatility-support-resistance-indicator/
//Nicolas @ prorealcode.com
upper = LinearRegression[10](close)+2.5*std[20](close)
lower = LinearRegression[10](close)-2.5*std[20](close)
atr = averagetruerange[40]
if upper<upper[1] and upper[1]>upper[2] then
r1 = upper[1]
rr2 = upper[1] - atr
endif
if lower>lower[1] and lower[1]<lower[2] then
s1 = lower[1]
s2 = lower[1] + atr
endif
if upper>upper[1] and upper[1]<upper[2] then
r3 = upper[1]
r4 = upper[1] - atr
endif
if lower<lower[1] and lower[1]>lower[2] then
s3 = lower[1]
s4 = lower[1] + atr
endif
period=10
x1=LinearRegression[period](close)
x2=2.5*STD[20](close)
h1=x1+x2
h2=x1-x2
return r1 coloured(100,100,0) style(dottedline,1) as "r1", rr2 coloured(100,100,0) style(dottedline,1) as "r2", s1 coloured(100,100,0) style(dottedline,1) as "s1", s2 coloured(100,100,0) style(dottedline,1) as "s2", r3 coloured(100,100,100) style(dottedline,1) as "r3", r4 coloured(100,100,100) style(dottedline,1) as "r4", s3 coloured(100,100,100) style(dottedline,1) as "s3", s4 coloured(100,100,100) style(dottedline,1) as "s4", h1 coloured(255,140,0) style(line,2) as "h1", h2 coloured(255,140,0) style(line,2) as "h2", x1