//
// @author Jadbrother modified by gero modified by ChaosTrader63
//
//@version=3
// @BGColor mod by goku972
study(title = “RCI 3 Lines”, shorttitle = “RCI3lines+BG”)
itvs = input(9, “short interval”)
itvm = input(26, “middle interval”)
itvl = input(52, “long interval”)
lengthSlope = input(1)
src = input(close, “source”)
upperband=input(title=”High line[%]”,defval=80,type=integer)
lowerband=input(title=”Low line[%]”,defval=-80,type=integer)
middleband=input(title=”Middle line[%]”,defval=-0,type=integer)
ord(seq, idx, itv) =>
p = seq[idx]
o = 1
s = 0
for i = 0 to itv – 1
if p < seq[i]
o := o + 1
else
if p == seq[i]
s := s+1
o+(s-1)/2.0
o
d(itv) =>
sum = 0.0
for i = 0 to itv – 1
sum := sum + pow((i + 1) – ord(src, i, itv), 2)
sum
rci(itv) => (1.0 – 6.0 * d(itv) / (itv * (itv * itv – 1.0))) * 100.0
hline(upperband,color=red,linestyle=dashed)
hline(lowerband,color=red,linestyle=dashed)
hline(middleband,color=green,linestyle=dashed)
plot(rci(itvs), title = “RCI short”, color = red)
plot(rci(itvm), title = “RCI middle”, color = blue)
plot(rci(itvl), title = “RCI long”, color = green)
//BG Color by RCI Long Line
//bgcolor(falling(rci(itvl), lengthSlope) ? maroon : (rising(rci(itvl), lengthSlope) ? green : black), transp=70)
//BG Color by RCI Middle Line
//bgcolor(falling(rci(itvm), lengthSlope) ? maroon : (rising(rci(itvm), lengthSlope) ? green : black), transp=70)
//BG Color by RCI Short Line
bgcolor(falling(rci(itvs), lengthSlope) ? maroon : (rising(rci(itvs), lengthSlope) ? green : black), transp=70)