//
// @sakura10gatu
//
//@version=3
//
study(title = "RCI with EMA&MACD test", shorttitle = "RCI with EMA&MACD test")
//rci
//itv09 = input(9, "interval 18")
itv18 = input(18, "RCI 1")
itv27 = input(27, "RCI 2")
itv36 = input(36, "RCI 3")
itv45 = input(56, "RCI 4")
itv56 = input(81, "RCI 5")
src = input(close, "source")
upperband=input(title="High line[%]",defval=80,type=integer)
lowerband=input(title="Low line[%]",defval=-80,type=integer)
ord(seq, idx, itv) =>
p = seq[idx]
o = 1
for i = 0 to itv - 1
if p < seq[i]
o := o + 1
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=gray,linestyle=dashed)
hline(lowerband,color=gray,linestyle=dashed)
//plot( rci(itv09), color=orange, style=line, title="rci09", linewidth=1)
plot( rci(itv18), color=red, style=line, title="rci1", linewidth=1)
plot( rci(itv27), color=blue, style=line, title="rci2", linewidth=1)
plot( rci(itv36), color=teal, style=line, title="rci3", linewidth=1)
plot( rci(itv45), color=green, style=line, title="rci4", linewidth=1)
plot( rci(itv56), color=navy, style=line, title="rci5", linewidth=2)