Untitled

 avatar
unknown
plain_text
a month ago
4.0 kB
5
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]
rsiHigh1 = math.max(rsi, rsi[1])
rsiLow1 = 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, rsiHigh1, rsiLow1, 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

rsiLengthInput = input.int(14, minval=1, title="RSI Length")
rsiSourceInput = input.source(close, "Source")
rsi1 = ta.rsi(rsiSourceInput, rsiLengthInput)
fiboLoopback = input.int(144, title="Fibo Loopback", minval=1)
// Fibonacci seviyelerinin hesaplanması
rsiHigh = ta.highest(rsi, fiboLoopback) // RSI üzerindeki en yüksek değer
rsiLow = ta.lowest(rsi, fiboLoopback) // RSI üzerindeki en düşük değer

// Fibonacci seviyeleri
fib0 = rsiLow
fib23_6 = rsiLow + (rsiHigh - rsiLow) * 0.236
fib38_2 = rsiLow + (rsiHigh - rsiLow) * 0.382
fib50 = rsiLow + (rsiHigh - rsiLow) * 0.5
fib61_8 = rsiLow + (rsiHigh - rsiLow) * 0.618
fib78_6 = rsiLow + (rsiHigh - rsiLow) * 0.786
fib100 = rsiHigh

// Fibonacci seviyelerinin çizilmesi
plot(fib0, title="Fib 0%", color=color.gray)
plot(fib23_6, title="Fib 23.6%", color=color.gray)
plot(fib38_2, title="Fib 38.2%", color=color.aqua)
plot(fib50, title="Fib 50%", color=color.red)
plot(fib61_8, title="Fib 61.8%", color=color.aqua)
plot(fib78_6, title="Fib 78.6%", color=color.gray)
plot(fib100, title="Fib 100%", color=color.gray)
Leave a Comment