Better RSI pine script

Did you know you can become a member of TTP for FREE if you join OKX using our link? ๐Ÿ˜ณ

We are back with signal school and today we are going to code a PineScript signal called “Better RSI” using TradingView.

During holidays I watched this video from PineTraders on YouTube and got inspired to code it for fun so I thought it would be a great idea to share it as part of these series.

If you are a member you don’t need to copy the code from the video, just login using your TTP membership ๐Ÿ™‚

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ยฉ TheTradingParrot

//@version=5
indicator("BRSI livestream")


trend = -2

if not na(trend[1])
    trend := trend[1]


rsi = ta.rsi(close, 14)

cross70 = ta.crossover(rsi, 70)
cross60 = ta.crossover(rsi, 60) and trend == -1
cross40 = ta.crossunder(rsi, 40) and trend == 1
cross30 = ta.crossunder(rsi, 30)


if cross70
    trend := 1
else if cross40 or cross60
    trend := 0
else if cross30
    trend := -1


trendcolor = trend == 1 ? color.green : trend == 0 ? color.gray : trend == -1 ? color.red : na


rsiplot = plot(rsi, "rsi", color = color.white)
trendplot = plot(50, "trend", color = trendcolor)

fill(rsiplot, trendplot, color = trendcolor)

hline(70)
hline(60)
hline(40)
hline(30)

buysignal = trend == 1 and ta.crossover(rsi, 50)
sellsignal = trend == -1 and ta.crossunder(rsi, 50)

plotshape(buysignal, "buy", shape.labelup, location.bottom, text = "B", textcolor = color.white, color = color.green)
plotshape(sellsignal, "sell", shape.labeldown, location.top, text = "S", textcolor = color.white, color = color.red)

plot(buysignal ? 1 : sellsignal ? 2 : na, "BRSI signal", color = na)




alertcondition(buysignal, "BRSI buy")
alertcondition(sellsignal, "BRSI sell")

Featured products and TTP memberships