OPEN-SOURCE SCRIPT

RSI with Zone Colors

51
//version=6
indicator(title="RSI with Zone Colors", shorttitle="RSI+", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

//// ==== INPUT SETTINGS ====
rsiLength = input.int(14, title="RSI Length", minval=1)
source = input.source(close, title="Source")
ob_level = input.int(70, title="Overbought Level")
os_level = input.int(30, title="Oversold Level")

//// ==== RSI CALCULATION ====
change = ta.change(source)
up = ta.ma(math.max(change, 0), rsiLength)
down = ta.ma(-math.min(change, 0), rsiLength)
rsi = down == 0 ? 100 : 100 - (100 / (1 + up / down))

//// ==== COLOR BASED ON ZONES ====
rsiColor = rsi > ob_level ? color.red : rsi < os_level ? color.green : #2962FF

//// ==== PLOT RSI ====
plot(rsi, title="RSI", color=rsiColor, linewidth=2)

//// ==== ZONE LINES ====
hline(ob_level, "Overbought", color=#787B86)
hline(50, "Middle", color=color.new(#787B86, 50))
hline(os_level, "Oversold", color=#787B86)

//// ==== FILL ZONES ====
zoneColor = rsi > ob_level ? color.new(color.red, 85) : rsi < os_level ? color.new(color.green, 85) : na

fill(plot(ob_level, display=display.none), plot(rsi > ob_level ? rsi : ob_level, display=display.none), color=zoneColor, title="OB Fill")
fill(plot(os_level, display=display.none), plot(rsi < os_level ? rsi : os_level, display=display.none), color=zoneColor, title="OS Fill")

//// ==== COLOR CANDLE WHEN RSI IN ZONE ====
barcolor(rsi > ob_level ? color.red : rsi < os_level ? color.green : na)

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.