RSI+OBV
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © email_analysts

//@version=5
indicator(title="DMI+RSI+OBV", overlay=false)
lensig = input.int(11, title="ADX Smoothing", minval=1, maxval=50)
len = input.int(11, minval=1, title="DI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
//plot(adx, color=#F50057, title="ADX")
plot(plus, color=color.green, title="+DI")
plot(minus, color=color.red, title="-DI")
hlineup = hline(40, color=#787B86)
hlinelow = hline(10, color=#787B86)


////////////////////////////////
len1 = input(title="OBV Length 1", defval = 3)
len2 = input(title="OBV Length 2", defval = 21)
ema1 = ta.ema(ta.obv, len1)
ema2 = ta.ema(ta.obv, len2)
obv=ema1-ema2

len3 = input(title="RSI Length 1", defval = 5)
len4 = input(title="RSI Length 2", defval = 9)
len5 = input(title="RSI Length 3", defval = 14)
sh = ta.rsi(close, len3)
sh9 = ta.rsi(close, len4)
ln = ta.ema(sh9, len5)
rsi = sh-ln

backgroundColor = obv >0 and rsi > 0 ? color.green:
                  obv < 0 and rsi < 0 ? color.red:
                  na

bgcolor(color=backgroundColor, transp=70)
