Page 1 of 1

Pls help on this script conversion

Posted: Mon Feb 05, 2024 5:30 am
by Deepu
Hi firends. This script is and old version. Please convert this into latest version and share it with me. thank you


study("RSI", overlay = true)

rsic(c) => //rsi custom
r = rsi(close[c],9)
r

rsi_low(l) => //rsi minima
v = rsic(1)<l and rsic(0)>rsic(1) and rsic(2)>rsic(1)
v

rsi_high(h) => //rsi minima
v = rsic(1)>h and rsic(0)<rsic(1) and rsic(2)<rsic(1)
v

rsi_gdiv() =>
a = false
b = barssince(rsi_low(30))
r1 = rsic(1)
r2 = valuewhen(b==0, rsic(1), 1)
r3 = valuewhen(b==0, rsic(1), 2)
p1 = close[1]
p2 = valuewhen(b==0, close[1], 1)
p3 = valuewhen(b==0, close[1], 2)
if rsi_low(30) and b[1]<5 and r1>r2 and p1<p2 //bull div
a := true
if rsi_low(30) and b[1]<5 and r1>r3 and p1<p3 //bull div
a := true
a

rsi_rdiv() =>
a = false
b = barssince(rsi_high(70))
r1 = rsic(1)
r2 = valuewhen(b==0, rsic(1), 1)
r3 = valuewhen(b==0, rsic(1), 2)
p1 = close[1]
p2 = valuewhen(b==0, close[1], 1)
p3 = valuewhen(b==0, close[1], 2)
if rsi_high(70) and b[1]<5 and r1<r2 and p1>p2 //bear div
a := true
if rsi_high(70) and b[1]<5 and r1<r3 and p1>p3 //bear div
a := true
a


plotshape(rsi_low(30), style=shape.triangleup,location=location.belowbar, color=orange)
plotshape(rsi_gdiv(), style=shape.triangleup,location=location.belowbar, color=white)

plotshape(rsi_high(70), style=shape.triangledown,location=location.abovebar, color=orange)
plotshape(rsi_rdiv(), style=shape.triangledown,location=location.abovebar, color=white)

//plot(rsi_rdiv())

Re: Pls help on this script conversion

Posted: Mon Feb 12, 2024 7:42 pm
by cjsgarbi
// This Pine Scriptâ„¢ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © investimentos254

//@version=5
indicator('RSI', overlay=true)

rsic(c) => //rsi custom
r = ta.rsi(close[c], 9)
r

rsi_low(l) => //rsi minima
v = rsic(1) < l and rsic(0) > rsic(1) and rsic(2) > rsic(1)
v

rsi_high(h) => //rsi minima
v = rsic(1) > h and rsic(0) < rsic(1) and rsic(2) < rsic(1)
v

rsi_gdiv() =>
a = false
b = ta.barssince(rsi_low(30))
r1 = rsic(1)
r2 = ta.valuewhen(b == 0, rsic(1), 1)
r3 = ta.valuewhen(b == 0, rsic(1), 2)
p1 = close[1]
p2 = ta.valuewhen(b == 0, close[1], 1)
p3 = ta.valuewhen(b == 0, close[1], 2)
if rsi_low(30) and b[1] < 5 and r1 > r2 and p1 < p2 //bull div
a := true
a
if rsi_low(30) and b[1] < 5 and r1 > r3 and p1 < p3 //bull div
a := true
a
a

rsi_rdiv() =>
a = false
b = ta.barssince(rsi_high(70))
r1 = rsic(1)
r2 = ta.valuewhen(b == 0, rsic(1), 1)
r3 = ta.valuewhen(b == 0, rsic(1), 2)
p1 = close[1]
p2 = ta.valuewhen(b == 0, close[1], 1)
p3 = ta.valuewhen(b == 0, close[1], 2)
if rsi_high(70) and b[1] < 5 and r1 < r2 and p1 > p2 //bear div
a := true
a
if rsi_high(70) and b[1] < 5 and r1 < r3 and p1 > p3 //bear div
a := true
a
a

plotshape(rsi_low(30), style=shape.triangleup, location=location.belowbar, color=color.new(color.orange, 0))
plotshape(rsi_gdiv(), style=shape.triangleup, location=location.belowbar, color=color.new(color.white, 0))

plotshape(rsi_high(70), style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0))
plotshape(rsi_rdiv(), style=shape.triangledown, location=location.abovebar, color=color.new(color.white, 0))

Re: Pls help on this script conversion

Posted: Thu Feb 15, 2024 10:37 am
by kellybasil
are you tryna create a RSI indicator with some additional features like detecting bullish and bearish divergence??