study(title="Apeiron RSI v2 Alarm", format=format.price, resolution="")
// Inputs || --------------------------------------------------------------------------------
len = 14
src = input(title="RSI Source", defval=close)
lbR =5
lbL = 5
rangeUpper = 60
rangeLower = 5
plotBull = true
plotHiddenBull = input(title="Gizli Boğa Gösterimi", defval=false)
plotBear = true
plotHiddenBear = input(title="Gizli Ayı Gösterimi", defval=false)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 0)
hiddenBearColor = color.new(color.red, 0)
textColor = color.white
noneColor = color.new(color.white, 100)
osc = rsi(src, len)
plot(osc, title="RSI", linewidth=1, color=color.gray,transp=20)
plFound = na(pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
// RSI Trend || --------------------------------------------------------------------------------
oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price Trend || ------------------------------------------------------------------------------
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)
priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)
priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)
priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)
// Divergence Defined || -----------------------------------------------------------------------
bullCond = plotBull and priceLL and oscHL and plFound
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
bearCond = plotBear and priceHH and oscLH and phFound
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
// Plots || -------------------------------------------------------------------------------------
plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Pozitif Uyumsuzluk",
linewidth=3,
color=(bullCond ? bullColor : noneColor),
transp=0
)
plotshape(
bullCond ? osc[lbR] : na,
offset=-lbR,
title="Pozitif Uyumsuzluk",
text=" P.U ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)
plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Gizli Boğa",
linewidth=3,
color=(hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)
plotshape(
hiddenBullCond ? osc[lbR] : na,
offset=-lbR,
title="Gizli Boğa",
text=" Trend Devam ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)
plotshape(
hiddenBearCond ? osc[lbR] : na,
offset=-lbR,
title="Gizli Ayı",
text=" Trend Devam ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
longCondition=bullCond or hiddenBullCond
plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Negatif Uyumsuzluk",
linewidth=3,
color=(bearCond ? bearColor : noneColor),
transp=0
)
...