Deepu
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: February 5th, 2024

Pls help on this script conversion

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())

cjsgarbi
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: February 12th, 2024
Contact: TradingView Profile

Re: Pls help on this script conversion

// 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))

kellybasil
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: December 27th, 2023
Contact: TradingView Profile

Re: Pls help on this script conversion

are you tryna create a RSI indicator with some additional features like detecting bullish and bearish divergence??

Return to “Share Your Scripts”