Money Maykah -- DC-ATR , Stochastic RSI signals v.1-89 --
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mrchiller505

//@version=5
indicator("DC  Stoch-RSI signal v.1-89", overlay = true)

// ---- Stoch RSI -----
var int smoothK = 3
var int smoothD = 3
lengthRSI = input.int(title='RSI Length',defval=21,minval=2)
lengthStoch = input.int(title='Stoch Length',defval=21,minval=2)
src_SRSI = close
rsi1 = ta.rsi(src_SRSI, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) // ploted as blue line
d = ta.sma(k, smoothD) // ploted at orange line

// ---- DC ----
DClen = input.int(20, minval=1)
lower = ta.lowest(DClen)
upper = ta.highest(DClen)
ATR_factor = input.float(0.5, minval=0.1)
ATR_length = input.int(14, minval=1)
ATR_sma_length = input.int(10, minval=1)
LLATR = lower - ta.sma(ATR_factor*ta.atr(ATR_length),ATR_sma_length)
LHATR = lower + ta.sma(ATR_factor*ta.atr(ATR_length),ATR_sma_length)
HHATR = upper + ta.sma(ATR_factor*ta.atr(ATR_length),ATR_sma_length)
HLATR = upper - ta.sma(ATR_factor*ta.atr(ATR_length),ATR_sma_length)
basis = math.avg(upper, lower)
plot(basis, "Basis", color=#f19f7e)
u = plot(upper, "Upper", color=#7ed3f1)
plot(HHATR, "HH ATR", color=#c32ad0)
plot(HLATR, "HL ATR", color=#c32ad0)
l = plot(lower, "Lower", color=#7ed3f1)
plot(LLATR, "LL ATR", color=#c32ad0)
plot(LHATR, "LH ATR", color=#c32ad0)
fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background")

// ---- Boolean check signals ----
sell_signal = input.int(title='Sell limit',defval=80,minval=50)
buy_signal = input.int(title='Buy limit',defval=20,maxval=50)
top_boolA =  (d > sell_signal) and d>k and (hl2 > basis)
ttop_boolA =  ta.crossunder(d,sell_signal) and (hl2 > basis)
btop_boolA = (d < buy_signal) and (hl2 > basis)
above_HL = high > HLATR
below_LH = low < LHATR
plotshape(top_boolA,title='d>sell,candle>basis',style=shape.triangleup, location=location.abovebar, color=above_HL?#ff4500:color.orange, size = size.tiny)
plotshape(ttop_boolA,title='crossunder',style=shape.xcross, location=location.abovebar, color=#eb9694  , size = size.tiny)
plotshape(btop_boolA,title='d<buy,candle>basis',style=shape.triangledown, location=location.belowbar, color=#eb8d68, size = size.tiny)

btm_boolA = (d < buy_signal) and d<k and (hl2 < basis)
bbtm_boolA = ta.crossover(d,buy_signal) and (hl2 < basis)
tbtm_boolA = (d > sell_signal) and (hl2 < basis)
plotshape(btm_boolA,title='d<buy,candle<basis',style=shape.triangledown, location=location.belowbar, color=below_LH?#6268e7:#7dbfe3,  size = size.tiny)
plotshape(bbtm_boolA,title='crossover',style=shape.xcross, location=location.belowbar, color=#8ed1fc,  size = size.tiny)
plotshape(tbtm_boolA,title='d>sell,candle<basis',style=shape.triangleup, location=location.abovebar, color=#bc68eb,  size = size.tiny)

