RSI & CCi SIGNAl
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ah_hoseyni_m

//@version=5
indicator(title="RSI & CCi SIGNAl" , shorttitle="RSI&CCI",  overlay=true, timeframe="", timeframe_gaps=true)

isShowSignalRsi = input.bool(title='Show RSI SIGNAl', defval=true, group="Signal")
isShowSignalCCI = input.bool(title='Show CCI SIGNAl', defval=true, group="Signal")
RavandType_ = input.string(title='RAVAND', defval='Both', options=['Ascending', 'Descending', 'Both'] , group="Signal")


ss = input.int(title='Sell Value RSI', defval=30, minval=1 , group="RSI")
bb = input.int(title='Buy Value RSI', defval=70, minval=2 , group="RSI")
srcRsi = input(close, title="Source CCI" , group="RSI")
LengthRsi = input.int(title="Length of the RSI", defval=14, minval=1 , group="RSI") 

lengthCCi = input.int(title="Length of the CCI", defval=20, minval=1, group="CCI") 
srcCCi = input(hlc3, title="Source CCI", group="CCI")



maCCI = ta.sma(srcCCi, lengthCCi)
ccivar = (srcCCi - maCCI) / (0.015 * ta.dev(srcCCi, lengthCCi))

rsiVar = ta.rsi(srcRsi,LengthRsi)
//rsiVar = ta.rsi(close,14)



longConditionRsi = ta.crossover(rsiVar , ss)
shortConditionRsi = ta.crossunder(rsiVar , bb)

longConditionCCI = ta.crossover(ccivar , -100)
shortConditionCCI = ta.crossunder(ccivar , 100)


plotshape(isShowSignalCCI and longConditionCCI and (RavandType_ == "Ascending" or RavandType_ == "Both"), style=shape.labelup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny, title='buy label CCI', text='B', textcolor=color.new(color.white, 0))
plotshape(isShowSignalCCI and shortConditionCCI  and (RavandType_ == "Descending" or RavandType_ == "Both") , style=shape.labeldown , location=location.abovebar, color=color.new(color.red, 0), size=size.tiny, title='sell label CCI', text='S', textcolor=color.new(color.white, 0))
alertcondition(isShowSignalCCI and longConditionCCI and (RavandType_ == "Ascending" or RavandType_ == "Both"), title='buy alarm CCI', message='buy signal CCi')
alertcondition(isShowSignalCCI and shortConditionCCI  and (RavandType_ == "Descending" or RavandType_ == "Both"), title='sell alarm CCI', message='sell signal CCI')




plotshape(isShowSignalRsi and longConditionRsi and (RavandType_ == "Ascending" or RavandType_ == "Both"), style=shape.labelup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny, title='buy label RSI', text='BUY', textcolor=color.new(color.white, 0))
plotshape(isShowSignalRsi and shortConditionRsi  and (RavandType_ == "Descending" or RavandType_ == "Both") , style=shape.labeldown , location=location.abovebar, color=color.new(color.red, 0), size=size.tiny, title='sell label RSI', text='SELL', textcolor=color.new(color.white, 0))
alertcondition(isShowSignalRsi and longConditionRsi and (RavandType_ == "Ascending" or RavandType_ == "Both"), title='buy alarm RSI', message='buy signal RSI')
alertcondition(isShowSignalRsi and shortConditionRsi  and (RavandType_ == "Descending" or RavandType_ == "Both"), title='sell alarm RSI', message='sell signal RSI')



