//@version=5
indicator('Everything Trend  (BY KHO_OLIO) -2024', shorttitle='EV TREND BY KHOOLIO-2024', overlay=true, max_bars_back=0, calc_bars_count=0, max_lines_count=500, max_labels_count=500, max_boxes_count=500, max_polylines_count=100, explicit_plot_zorder = true)






//HL price 
pchon=input(true,title ='HLC Price ')
ob_high = ta.highest(high, 1)
ob_low = ta.lowest(low, 1)
ob_mid = close
pchc = if pchon==true
    pchc= display.all
else
    pchc= display.none
pchcx = if pchon==true
    pchcx= 70
else
    pchcx= 100
ob1=plot(ob_high, "High", color=color.new(color.black,0), linewidth = 1,editable = false,display = display.none)
ob2=plot(ob_low, "Low", color = color.new(color.black,0), linewidth = 1,editable = false,display = display.none)
ob3=plot(ob_mid, "Price", color = color.new(color.black,0), linewidth = 2,editable = false,display = pchc)
fill(ob1,ob3,color = color.new(color.orange,pchcx),editable = false)
fill(ob2,ob3,color = color.new(color.aqua,pchcx),editable = false)









//waves
maon=input(true,title =' Heat Waves')
bandperiod1   = input(38, title='MA-1',inline = 'HMW')
bandperiod2   = input(50, title='MA-2',inline = 'HMW')
bandperiod3   = input(62, title='MA-3',inline = 'HMW')
bandperiod4   = input(79, title='MA-4',inline = 'HMW')
normal1 = ta.ema(high, bandperiod1)
normal2 = ta.ema(low, bandperiod1)
normal3 = ta.ema(high, bandperiod2)
normal4 = ta.ema(low, bandperiod2)
normal5 = ta.ema(high, bandperiod3)
normal6 = ta.ema(low, bandperiod3)
normal7 = ta.ema(high, bandperiod4)
normal8 = ta.ema(low, bandperiod4)
normal9  = ta.wma(high, bandperiod1)
normal10 = ta.wma(low, bandperiod1)
normal11 = ta.wma(high, bandperiod2)
normal12 = ta.wma(low, bandperiod2)
normal13 = ta.wma(high, bandperiod3)
normal14 = ta.wma(low, bandperiod3)
normal15 = ta.wma(high, bandperiod4)
normal16 = ta.wma(low, bandperiod4)
normal1color = normal1 > normal1[1] ? color.aqua : normal1 < normal1[1] ? color.orange : na
normal2color = normal2 > normal2[1] ? color.aqua : normal2 < normal2[1] ? color.orange : na
normal3color = normal3 > normal3[1] ? color.aqua : normal3 < normal3[1] ? color.orange : na
normal4color = normal4 > normal4[1] ? color.aqua : normal4 < normal4[1] ? color.orange : na
normal5color = normal5 > normal5[1] ? color.aqua : normal5 < normal5[1] ? color.orange : na
normal6color = normal6 > normal6[1] ? color.aqua : normal6 < normal6[1] ? color.orange : na
normal7color = normal7 > normal7[1] ? color.aqua : normal7 < normal7[1] ? color.orange : na
normal8color = normal8 > normal8[1] ? color.aqua : normal8 < normal8[1] ? color.orange : na
normal9color = normal9 > normal9[1] ? color.aqua : normal9 < normal9[1] ? color.orange : na
normal10color = normal10 > normal10[1] ? color.aqua : normal10 < normal10[1] ? color.orange : na
normal11color = normal11 > normal11[1] ? color.aqua : normal11 < normal11[1] ? color.orange : na
normal12color = normal12 > normal12[1] ? color.aqua : normal12 < normal12[1] ? color.orange : na
normal13color = normal13 > normal13[1] ? color.aqua : normal13 < normal13[1] ? color.orange : na
normal14color = normal14 > normal14[1] ? color.aqua : normal14 < normal14[1] ? color.orange : na
normal15color = normal15 > normal15[1] ? color.aqua : normal15 < normal15[1] ? color.orange : na
normal16color = normal16 > normal16[1] ? color.aqua : normal16 < normal16[1] ? color.orange : na
tramax= if maon == true
    tramax=display.all
else
    tramax=display.none
MA2= plot(normal2, title='A1-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal2color,70), display= tramax,editable = false)
MA1  = plot(normal1, title='A1-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal1color,70), display= tramax,editable = false)
MA3  = plot(normal3, title='A2-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal3color,70), display= tramax,editable = false)
MA4= plot(normal4, title='A2-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal4color,70), display= tramax,editable = false)
MA5  = plot(normal5, title='A3-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal5color,70), display= tramax,editable = false)
MA6= plot(normal6, title='A3-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal6color,70), display= tramax,editable = false)
MA7  = plot(normal7, title='A4-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal7color,70), display= tramax,editable = false)
MA8= plot(normal8, title='A4-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal8color,70), display= tramax,editable = false)
MA9  = plot(normal9, title='B1-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal9color,70), display= tramax,editable = false)
MA10 = plot(normal10, title='B1-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal10color,70),display = tramax,editable = false)
MA11   = plot(normal11, title='B2-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal11color,70),display = tramax,editable = false)
MA12 = plot(normal12, title='B2-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal12color,70),display = tramax,editable = false)
MA13   = plot(normal13, title='B3-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal13color,70),display = tramax,editable = false)
MA14 = plot(normal14, title='B3-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal14color,70),display = tramax,editable = false)
MA15   = plot(normal15, title='B4-(Up Band)', style=plot.style_line, linewidth=1, color=color.new(normal15color,70),display = tramax,editable = false)
MA16 = plot(normal16, title='B4-(Down Band)', style=plot.style_line, linewidth=1, color=color.new(normal16color,70),display = tramax,editable = false)










//MSC%
mscp=input(true,title ='Market Sentiment Channel percent')
len = input.int(62, title='Length', minval=1, step=1)
hpx = ta.highest(high,len)
hpxc = ta.highest(close,len)
lpx = ta.lowest(low,len)
lpxc = ta.lowest(close,len)
calh = ((close - lpx) / (hpx - lpx)) *100
call = (100 - calh)
psc = if mscp==true
    psc=70
else
    psc=100
pscx = if mscp==true
    pscx=0
else
    pscx=100
hpxl=plot(hpx, title='LatestBullieshPower',style = plot.style_stepline, color=color.new(color.red,100) ,linewidth = 1,editable = false)
hpxcl=plot(hpxc, title='LatestBullieshPower',style = plot.style_stepline, color=color.new(color.red,100) ,linewidth = 1,editable = false)
lpxl=plot(lpx, title='LatestBearieshPower', style=plot.style_stepline, color=color.new(color.teal,100) ,linewidth = 1,editable = false)
lpxcl=plot(lpxc, title='LatestBearieshPower', style=plot.style_stepline, color=color.new(color.teal,100) ,linewidth = 1,editable = false)
fill(hpxl,hpxcl,color = color.new(color.black,psc),editable = false)
fill(lpxl,lpxcl,color = color.new(color.black,psc),editable = false)
pxbh=label.new(bar_index+25, (hpx+hpxc)/2 , text =('SUPPLY' +'\n'+  (str.tostring(hpxc)) +' TO '+(str.tostring(hpx)) +'\n'+'BEARISH: '+(str.tostring(call,format.percent))),style=label.style_label_left, size=size.normal,text_font_family = font.family_default, color=color.new(color.black, pscx), textcolor=color.new(color.white,pscx),textalign= text.align_center)
label.delete(pxbh[1])
pxbl=label.new(bar_index+25, (lpx+lpxc)/2 , text =('DEMAND' +'\n'+  (str.tostring(lpxc)) +' TO '+(str.tostring(lpx)) +'\n'+'BULLISH: '+ (str.tostring(calh,format.percent))),style=label.style_label_left, size=size.normal,text_font_family = font.family_default, color=color.new(color.black, pscx), textcolor=color.new(color.white,pscx))
label.delete(pxbl[1])
ps1 = (hpx > hpx[1])
ps2 = (lpx < lpx[1])
ps1c = if mscp==true
    ps1c=0
else
    ps1c=100
ps2c = if mscp==true
    ps2c=0
else
    ps2c=100
plotshape(ps1, title='Latest Bulliesh Power', style=shape.triangleup, color=color.new(color.aqua,ps1c) ,size=size.tiny, location=location.abovebar,editable = false)
plotshape(ps2, title='LatestBearieshPower', style=shape.triangledown, color=color.new(color.orange,ps2c) , size=size.tiny, location=location.belowbar,editable = false)








//xx
xxch=input(true,title ='Trend Channel')
xxchc = if xxch==true
    xxchx=50
else
    xxchc=100
length = input.float(500,'length',maxval=500,minval=0)
hx      = input.float(38,'Bandwidth',step = 0.001)
mult   = input.float(2.618,'multiple',step = 0.001) 
n = bar_index
var k = 2
var upper = array.new_line(0) 
var lower = array.new_line(0)

lset(l,x1,y1,x2,y2,col)=>
    line.set_xy1(l,x1,y1)
    line.set_xy2(l,x2,y2)
    line.set_color(l,col)
    line.set_width(l,1)
if barstate.isfirst
    for i = 0 to length/k-1
        array.push(upper,line.new(na,na,na,na))
        array.push(lower,line.new(na,na,na,na))

line up = na
line dn = na

if barstate.islast
    y = array.new_float(0)
    
    sum_e = 0.
    for i = 0 to length-1
        sum = 0.
        sumw = 0.
        
        for j = 0 to length-1
            w = math.exp(-(math.pow(i-j,2)/(hx*hx*2)))
            sum += close[j]*w
            sumw += w
        
        y2 = sum/sumw
        sum_e += math.abs(close[i] - y2)
        array.push(y,y2)

    mae = sum_e/length*mult
    
    for i = 1 to length-1
        y2 = array.get(y,i)
        y1 = array.get(y,i-1)
        
        up := array.get(upper,i/k)
        dn := array.get(lower,i/k)
        
        upc=(y1+mae)<(y2+mae)?color.orange:(y1+mae)>(y2+mae)?color.aqua:na
        dnc=(y1-mae)>(y2-mae)?color.aqua:(y1-mae)<(y2-mae)?color.orange:na

        lset(up,n-i+15,y1 + mae,n-i,y2 + mae,color.new(upc,xxchc))
        lset(dn,n-i+15,y1 - mae,n-i,y2 - mae,color.new(dnc,xxchc))


        







//lOGO --------------------------------------------------------------------------------------- //
// ---------------------------------------------------------------------------------------------- //

var table logo = table.new(position.middle_left, 1, 1)
if barstate.islast
    table.cell(logo, 0, 0, '𝕂ℍ𝕆𝕆𝕃𝕀𝕆-𝟚𝟘𝟚𝟜', text_size=size.normal, text_color=#ff0000)
//