OPEN-SOURCE SCRIPT

REVERSÃO POR ZONA DE RSI- INICIA CRYPTO

//version=5

indicator('REVERSÃO POR ZONA DE RSI- INICIA CRYPTO ', overlay=false)

//functions
xrf(values, length) =>
r_val = float(na)
if length >= 1
for i = 0 to length by 1
if na(r_val) or not na(values)
r_val := values
r_val
r_val
xsa(src, len, wei) =>
sumf = 0.0
ma = 0.0
out = 0.0
sumf := nz(sumf[1]) - nz(src[len]) + src
ma := na(src[len]) ? na : sumf / len
out := na(out[1]) ? ma : (src * wei + out[1] * (len - wei)) / len
out


// inputs
n1 = input.int(30, title='n1', minval=1)

//threshold lines
h1 = hline(50, color=color.red, linestyle=hline.style_dotted)
h2 = hline(50, color=color.green, linestyle=hline.style_dotted)
h3 = hline(10, color=color.lime, linestyle=hline.style_dotted)
h4 = hline(90, color=color.red, linestyle=hline.style_dotted)
fill(h2, h3, color=color.new(color.green, 70))
fill(h1, h4, color=color.new(color.red, 70))

//KDJ indicator
rsv = (close - ta.lowest(low, n1)) / (ta.highest(high, n1) - ta.lowest(low, n1)) * 100
k = xsa(rsv, 3, 1)
d = xsa(k, 3, 1)
crossover_1 = ta.crossover(k, d)
buysig = d < 25 and crossover_1 ? 30 : 0
crossunder_1 = ta.crossunder(d, k)
selsig = d > 75 and crossunder_1 ? 70 : 100

//plot buy and sell signal
ple = plot(buysig, color=color.new(color.green, 0), linewidth=1, style=plot.style_area)
pse = plot(selsig, color=color.new(color.red, 0), linewidth=2, style=plot.style_line)

//plot KD candles
plotcandle(k, d, k, d, color=k >= d ? color.green : na)
plotcandle(k, d, k, d, color=d > k ? color.red : na)

// KDJ leading line
var1 = (close - ta.sma(close, 13)) / ta.sma(close, 13) * 100
var2 = (close - ta.sma(close, 26)) / ta.sma(close, 21) * 100
var3 = (close - ta.sma(close, 90)) / ta.sma(close, 34) * 100
var4 = (var1 + 3 * var2 + 9 * var3) / 13
var5 = 100 - math.abs(var4)
var10 = ta.lowest(low, 10)
var13 = ta.highest(high, 25)
leadingline = ta.ema((close - var10) / (var13 - var10) * 4, 4) * 25
pbias = plot(leadingline, color=k >= d ? color.green : color.red, linewidth=4, style=plot.style_line, transp=10)


Relative Strength Index (RSI)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer