Untitled

 avatar
unknown
plain_text
2 months ago
2.9 kB
3
Indexable
//@version=5
indicator("RSI mum", shorttitle="RSI mum", overlay=false)

// Inputs
src = close
len = input.int(14, minval=1, title="RSI Length")
upLine = input.int(70, minval=50, maxval=90, title="Upper Line Value?")
lowLine = input.int(30, minval=10, maxval=50, title="Lower Line Value?")
midLine = 50

// RSI Calculation
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// Define RSI Candle Data
rsiOpen = rsi[1]
rsiHigh = math.max(rsi, rsi[1])
rsiLow = math.min(rsi, rsi[1])
rsiClose = rsi

// Main Chart Candle Colors
candleColor = close > open ? color.new(color.green, 0) : color.new(color.red, 0)

// Plot RSI Candlesticks
plotcandle(rsiOpen, rsiHigh, rsiLow, rsiClose, title="RSI Candles", color=candleColor)

// Draw RSI Levels
hline(upLine, "Upper Level", color=color.new(color.red, 0), linewidth=1, linestyle=hline.style_dotted)
hline(lowLine, "Lower Level", color=color.new(color.green, 0), linewidth=1, linestyle=hline.style_dotted)
hline(midLine, "Mid Level", color=color.new(color.gray, 0), linewidth=1, linestyle=hline.style_dotted)

// Fill Areas Between Levels for Visualization
//bgcolor(rsi > upLine ? color.new(color.red, 90) : na, title="Overbought Highlight")
//bgcolor(rsi < lowLine ? color.new(color.green, 90) : na, title="Oversold Highlight")
sbh = input.bool(true, title="Show Back Ground Highlights When RSI is Above/Below High/Low Lines?")
sch = input.bool(true, title="Show Back Ground Highlights When RSI Cross?")
// Conditions
useCurrentRes = input.bool(true, title="Use Current Chart Resolution?")
resCustom = input.timeframe(title="Use Different Timeframe? Uncheck Box Above", defval="60")
ssRSI = input.bool(false, title="Show 2nd RSI?")
resCustom2 = input.timeframe(title="Use 2nd RSI? Check Box Above", defval="D")
useCurrentRes2 = input.bool(false, title="Use 2nd RSI Plot On Same Timeframe?")
// Timeframe Selection
res = useCurrentRes ? timeframe.period : resCustom
res2 = useCurrentRes2 ? timeframe.period : resCustom2
outRSI = request.security(syminfo.tickerid, res, rsi)
aboveLine = outRSI > upLine ? 1 : 0
belowLine = outRSI < lowLine ? 1 : 0
crossUp = outRSI[1] < lowLine and outRSI > lowLine ? 1 : 0
crossDn = outRSI[1] > upLine and outRSI < upLine ? 1 : 0
// Background Highlights
//bgcolor(sbh and aboveLine ? color.new(color.red, 70) : na, transp=70) // RSI üst sınırın üzerindeyse kırmızı arka plan
//bgcolor(sbh and belowLine ? color.new(color.green, 70) : na, transp=70) // RSI alt sınırın altındaysa yeşil arka plan
bgcolor(sch and crossUp ? color.new(color.lime, 40) : na, transp=40) // RSI alt sınırdan yukarı keserse lime rengi
bgcolor(sch and crossDn ? color.new(color.red, 40) : na, transp=40) // RSI üst sınırdan aşağı keserse kırmızı rengi
Leave a Comment