The Phi Club - Dick Diamonds Indicator 1
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ThePhiClub

//@version=4
study(title="The Phi Club", shorttitle="Dick Diamonds Indicator 1", overlay=false)

requiredBars = input(title="Required bars", type=input.integer, defval=20, minval=2, step=1)
overBought = input(title="Overbought region", defval=70, minval=51, maxval=100, step=1)
overSold = input(title="Oversold region", defval=30, minval=1, maxval=49, step=1)

sRSI = rsi(close, 3)
sMA = sma(sRSI, 3)

conditionUpArrow = if ((sMA > sMA[1]) and (sMA[1] < sMA[2]) and (sMA[1] < overSold))
    1
else
    na

conditionDownArrow = if ((sMA < sMA[1]) and (sMA[1] > sMA[2]) and (sMA[1] > overBought))
    1
else
    na
    
hline(title='OB', price=overBought, color=color.silver)
hline(title='OS', price=overSold, color=color.silver)
plot(series=sRSI, title="RSI", color=color.red)
plot(series=sMA, title="MA", color=color.blue)
plotshape(conditionUpArrow, style=shape.arrowup, color=color.green, size=size.auto, location=location.bottom)
plotshape(conditionDownArrow, style=shape.arrowdown, color=color.red, size=size.auto, location=location.top)

