//@version=5
//Idea by ALKHO_OLY on APR 7, 2022.


indicator('ULTIMATE-12IN1 (BY KHO_OLIO)-2023', shorttitle='12IN1 FRAME BY KHOOLIO-2023', overlay=false, timeframe="", timeframe_gaps=true)

// Check for higher highs and lower lows


//BANDS strength
normal1 = ta.ema(high, 4)
normal2 = ta.ema(low, 4)
normal3 = ta.ema(high, 7)
normal4 = ta.ema(low, 7)
normal5 = ta.wma(high, 4)
normal6 = ta.wma(low, 4)
normal7 = ta.wma(high, 7)
normal8 = ta.wma(low, 7)
up1 = normal1 > normal3 and normal2 > normal4
down1 = normal2 < normal4 and normal1 < normal3
up2 = normal5 > normal7 and normal6 > normal8
down2 = normal6 < normal8 and normal5 < normal7
bandupi = up1 and up2 and normal1 > normal1[1] and normal3 > normal3[1] and normal2 > normal2[1] and normal4 > normal4[1] and normal5 > normal5[1] and normal7 > normal7[1] and normal6 > normal6[1] and normal8 > normal8[1]
banddowni = down1 and down2 and normal2 < normal2[1] and normal4 < normal4[1] and normal1 < normal1[1] and normal3 < normal3[1] and normal6 < normal6[1] and normal8 < normal8[1] and normal5 < normal5[1] and normal7 < normal7[1]



//MACD strength 
fast = ta.ema(close, 50)
slow = ta.ema(close, 64)
MACD = fast - slow
signal = ta.ema(MACD, 47)
hist = MACD - signal
macdupi = MACD > signal and hist > hist[1] or MACD < signal and hist > hist[1]
macddowni = MACD < signal and hist < hist[1] or MACD > signal and hist < hist[1]



//PARABOLICSAR strength
out = ta.sar(0.02, 0.022, 0.2)
sarupi = close > out and out > out[1]
sardowni = close < out and out < out[1]



//RSI strength 
RSI1s = ta.rma(ta.rsi(close, 14), 7)
RSI1 = ta.sma(RSI1s, 7)
RSI2s = ta.rma(RSI1, 7)
RSI2 = ta.sma(RSI2s, 7)
rsiupi = RSI1 > RSI2
rsidowni = RSI1 < RSI2



//Stochastic strength
STOCHKs = ta.rma(ta.stoch(close, high, low, 14), 3)
STOCHK = ta.sma(STOCHKs, 3)
STOCHDs = ta.rma(STOCHK, 3)
STOCHD = ta.sma(STOCHDs, 3)
stochupi = STOCHK > STOCHD
stochdowni = STOCHK < STOCHD



//CCI strength
CCI1s = ta.rma(ta.cci(close, 14), 14)
CCI1 = ta.sma(CCI1s, 14)
CCI2s = ta.rma(CCI1, 4)
CCI2 = ta.sma(CCI2s, 4)
cciupi = CCI1 > CCI2
ccidowni = CCI1 < CCI2



//ADX strength
TrueRange = math.max(math.max(high - low, math.abs(high - nz(close[1]))), math.abs(low - nz(close[1])))
DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? math.max(high - nz(high[1]), 0) : 0
DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? math.max(nz(low[1]) - low, 0) : 0
SmoothedTrueRange = nz(TrueRange[1]) - nz(TrueRange[1]) / 14 + TrueRange
SmoothedDirectionalMovementPlus = nz(DirectionalMovementPlus[1]) - nz(DirectionalMovementPlus[1]) / 14 + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = nz(DirectionalMovementMinus[1]) - nz(DirectionalMovementMinus[1]) / 14 + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = math.abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX = ta.sma(DX, 14)
ADIPLUS = ta.sma(DIPlus, 14)
ADIMINUS = ta.sma(DIMinus, 14)
adxupi = ADIPLUS > ADIMINUS and ADX > 20
adxdowni = ADIPLUS < ADIMINUS and ADX > 20



//ATR strength 
atr2s = ta.ema(ta.tr, 7)
atr2 = ta.ema(atr2s, 7)
atr = ta.atr(7)
up = hl2 - 0.4 * atr
upr = nz(up[1], up)
up := close[1] > upr ? math.max(up, upr) : up
dn = hl2 + 0.4 * atr
dnr = nz(dn[1], dn)
dn := close[1] < dnr ? math.min(dn, dnr) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dnr ? 1 : trend == 1 and close < upr ? -1 : trend
Atrup = trend == 1 and trend[1] == -1
Atrdown = trend == -1 and trend[1] == 1
atrup = close > upr and trend == 1
atrdown = close < dnr and trend == -1



//Trend direction&strengthBars
td1s = ta.rma(close, 4)
td1 = ta.sma(td1s, 4)
td2s = ta.rma(open, 4)
td2 = ta.sma(td2s, 4)
tdup = td1 > td2
tddown = td1 < td2
tdupi = tdup
tddowni = tddown
tdups = tdup
tddowns = tddown
tbupi = tdup and close > td1
tbdowni = tddown and close < td1



//volume 
p1 = close
v1 = volume
p2 = p1[21]
v2 = v1[21]
va1 = p1 > p2 and v1 > v2
va2 = p1 > p2 and v1 < v2
va3 = p1 < p2 and v1 < v2
va4 = p1 < p2 and v1 > v2
vaupi = va1 or va2
vadowni = va3 or va4



//Bullish & Bearish strength 
bbsource = (close > open) ? (high-low) : (low-high)
bbupi = (ta.ema(bbsource, 3)) > 0
bbdowni = (ta.ema(bbsource, 3)) < 0



//Indicator strength&alert
x = 1
y = -1
z = 0
bandupn = bandupi ? x : z
banddownn = banddowni ? y : z
macdupn = macdupi ? x : z
macddownn = macddowni ? y : z
sarupn = sarupi ? x : z
sardownn = sardowni ? y : z
rsiupn = rsiupi ? x : z
rsidownn = rsidowni ? y : z
stochupn = stochupi ? x : z
stochdownn = stochdowni ? y : z
cciupn = cciupi ? x : z
ccidownn = ccidowni ? y : z
adxupn = adxupi ? x : z
adxdownn = adxdowni ? y : z
atrupn = atrup ? x : z
atrdownn = atrdown ? y : z
tdupn = tdupi ? x : z
tddownn = tddowni ? y : z
tbupn = tbupi ? x : z
tbdownn = tbdowni ? y : z
vaupn = vaupi ? x : z
vadownn = vadowni ? y : z
bbupn = bbupi ? x : z
bbdownn = bbdowni ? y : z
a = bandupn == 0 and banddownn == 0
b = macdupn == 0 and macddownn == 0
c = sarupn == 0 and sardownn == 0
d = rsiupn == 0 and rsidownn == 0
e = stochupn == 0 and stochdownn == 0
f = cciupn == 0 and ccidownn == 0
g = adxupn == 0 and adxdownn == 0
h = atrupn == 0 and atrdownn == 0
i = tdupn == 0 and tddownn == 0
j = tbupn == 0 and tbdownn == 0
k = vaupn == 0 and vadownn == 0
m = bbupn == 0 and bbdownn == 0
bandn = a ? x : z
macdn = b ? x : z
sarn = c ? x : z
rsin = d ? x : z
stochn = e ? x : z
ccin = f ? x : z
adxn = g ? x : z
atrn = h ? x : z
tdn = i ? x : z
tbn = j ? x : z
van = k ? x : z
bbn = m ? x : z

indicatorresualt = bandupn + banddownn + macdupn + macddownn + sarupn + sardownn + rsiupn + rsidownn + stochupn + stochdownn + cciupn + ccidownn + adxupn + adxdownn + atrupn + atrdownn + tdupn + tddownn + tbupn + tbdownn + vaupn + vadownn + bbupn + bbdownn
indicatoractive = (bandn + macdn + sarn + rsin + stochn + ccin + adxn + atrn + tdn + tbn + van + bbn) -12
indicatorsource = indicatorresualt / indicatoractive * -12
indicatorp = input(defval = 80, title='indicator Length')
ipush = ta.rma(indicatorsource, indicatorp)
[supertrend, direction] = ta.supertrend(indicatorp/100, indicatorp)
ipushcolor1 = (direction < 0) ? color.new(color.gray,70) : (direction > 0) ? color.new(color.black,40): na  
plot(ipush, title='Market Sentiments Moves', style=plot.style_areabr, linewidth=1, color=ipushcolor1)
l0= hline(0,'CENTER',color.black,hline.style_solid,1)
l1= hline(2,'R1',color.new(color.red, 50),hline.style_solid,1)
l3= hline(4,'R2',color.new(color.red, 50),hline.style_solid,2)
l5= hline(6,'R3',color.new(color.red, 60),hline.style_solid,3)
l2= hline(-2,'S1',color.new(color.teal, 50),hline.style_solid,1)
l4= hline(-4,'S2',color.new(color.teal, 50),hline.style_solid,2)
l6= hline(-6,'S3',color.new(color.teal, 60),hline.style_solid,3)
l01= hline(0.8,'CorrectionArea-UpperBand', color.black, hline.style_dotted,2)
l02= hline(-0.8,'CorrectionArea-LowerBand',color.black, hline.style_dotted,2)
fill(l01,l02,title='CorrectionArea',color=color.new(color.yellow,90))


//fibonacci
high_point = ta.highest(ipush,indicatorp)
low_point = ta.lowest(ipush, indicatorp)
fib0 = high_point
fib1 = low_point
f4p = plot(fib1, title='Support', style=plot.style_linebr, linewidth=2, color=color.new(color.black,0))
f0p = plot(fib0, title='Resistance', style=plot.style_linebr, linewidth=2, color=color.new(color.black,0))
f0c = (fib0 > fib0[1]) ? color.new(color.green, 0) :na
f0pp= plot(fib0, title= 'Bullish-Break/R', style=plot.style_stepline_diamond, linewidth=2, color=f0c)
f1c = (fib1 < fib1[1]) ? color.new(color.red, 0) :na
f4pp= plot(fib1, title= 'Bearish-Break/S', style=plot.style_stepline_diamond, linewidth=2, color=f1c)