Chanu Delta RSI Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chanu_lev10k

//@version=5
strategy(title='Chanu Delta RSI Strategy', overlay=false)

// Inputs
sym_ref = input.symbol(title='BTCUSD reference market', defval='BYBIT:BTCUSDT')
sym_amp = input.symbol(title='BTCUSD large amplitude market', defval='COINBASE:BTCUSD')
src = input.source(title='Source', defval=close)
res = input.timeframe(title='Resolution', defval='')
isnorm = input.bool(title='Use Normalization of Chanu Delta ?', defval=true, tooltip='By dividing the original Chanu Delta value by the price of the reference Bitcoin market, it allows the Chanu Delta strategy to be universally used in the long term despite Bitcoin price fluctuations.')
len = input.int(defval=4, title='Length of Chanu Delta RSI')
bullLevel = input.int(title='Bull Level', defval=63, maxval=100, minval=0)
bearLevel = input.int(title='Bear Level', defval=30, maxval=100, minval=0)
highlightBreakouts = input(title='Highlight Bull/Bear Breakouts ?', defval=true)

// Chanu Delta RSI Definition
delta_f(res, src) =>
    d = request.security(sym_amp, res, src) - request.security(sym_ref, res, src)
    n = d / request.security(sym_ref, res, src) * 100000
    isnorm ? n : d
delta = delta_f(res, src)
delta_rsi = ta.rsi(delta, len)

// Plot
rcColor = delta_rsi > bullLevel ? #0ebb23 : delta_rsi < bearLevel ? #ff0000 : #f4b77d
maxBand = hline(100, title='Max Level', linestyle=hline.style_dotted, color=color.white)
hline(0, title='Zero Level', linestyle=hline.style_dotted)
minBand = hline(0, title='Min Level', linestyle=hline.style_dotted, color=color.white)
bullBand = hline(bullLevel, title='Bull Level', linestyle=hline.style_dotted)
bearBand = hline(bearLevel, title='Bear Level', linestyle=hline.style_dotted)
fill(bullBand, bearBand, color=color.new(color.purple, 95))
bullFillColor = delta_rsi > bullLevel and highlightBreakouts ? color.green : na
bearFillColor = delta_rsi < bearLevel and highlightBreakouts ? color.red : na
fill(maxBand, bullBand, color=color.new(bullFillColor, 80))
fill(minBand, bearBand, color=color.new(bearFillColor, 80))
plot(delta_rsi, title='Chanu Delta RSI', linewidth=2, color=rcColor)

// Long Short conditions
longCondition = ta.crossover(delta_rsi, bullLevel)
if longCondition
    strategy.entry('Long', strategy.long)
shortCondition = ta.crossunder(delta_rsi, bearLevel)
if shortCondition
    strategy.entry('Short', strategy.short)