OPEN-SOURCE SCRIPT

Reverse RSI

137
//version=6
indicator("Reverse RSI", overlay=false)

rsi_length = input.int(14, title="RSI Length", minval=1)
ob_level = input.int(75, title="Overbought Level")
os_level = input.int(25, title="Oversold Level")

invRSI(target, length) =>
target_rs = target / (100 - target)

up = math.max(close-close[1], 0)
down = math.max(close[1]-close, 0)

prev_avg_up = ta.rma(up, length)
prev_avg_down = ta.rma(down, length)


price_up = target_rs * (prev_avg_down * (length - 1)) - (prev_avg_up * (length - 1)) + close
price_down = (prev_avg_down * (length - 1) - (prev_avg_up * (length - 1)) / target_rs) + close

current_rsi = ta.rsi(close, length)
price = target > current_rsi ? price_up : price_down
price

price_ob = invRSI(ob_level, rsi_length)
price_mid = invRSI(50, rsi_length)
price_os = invRSI(os_level, rsi_length)

upside = (price_ob-close)/close*100
downside = (close-price_os)/close*100
net = upside-downside

plot(upside, title="Upside Line", color=color.green)
plot(downside, title="Downside Line", color=color.red)
plot(net, title="Net Line", color=net>0?color.new(color.green, 30):color.new(color.red, 30), style=plot.style_columns)

hline(0, "Zero Line")

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.