Sembang Kari Traders - EMA & Wave Stacked Labels + EMA 34 Lines
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// Stacked EMAs & Waves Labels on multiple timeframe
//
// EMA 34 Lines (Close, High and Low)
//
// Created by © Hadi
// 

indicator("Stacked EMAs", overlay = true)

// EMAs

ema34dh = ta.ema (high, 34)
ema34d = ta.ema (close, 34)
ema34dl = ta.ema (low, 34)
ema200 = ta.ema (close, 200)

ema85 = request.security(syminfo.tickerid, '5', ta.ema(close, 8))
ema215 = request.security(syminfo.tickerid, '5', ta.ema(close, 21))
ema345 = request.security(syminfo.tickerid, '5', ta.ema(close, 34))
ema555h = request.security(syminfo.tickerid, '5', ta.ema(high, 55))
ema555c = request.security(syminfo.tickerid, '5', ta.ema(close, 55))
ema555l = request.security(syminfo.tickerid, '5', ta.ema(low, 55))

ema815 = request.security(syminfo.tickerid, '15', ta.ema(close, 8))
ema2115 = request.security(syminfo.tickerid, '15', ta.ema(close, 21))
ema3415 = request.security(syminfo.tickerid, '15', ta.ema(close, 34))
ema5515h = request.security(syminfo.tickerid, '15', ta.ema(high, 55))
ema5515c = request.security(syminfo.tickerid, '15', ta.ema(close, 55))
ema5515l = request.security(syminfo.tickerid, '15', ta.ema(low, 55))

ema830 = request.security(syminfo.tickerid, '30', ta.ema(close, 8))
ema2130 = request.security(syminfo.tickerid, '30', ta.ema(close, 21))
ema3430 = request.security(syminfo.tickerid, '30', ta.ema(close, 34))
ema5530h = request.security(syminfo.tickerid, '30', ta.ema(high, 55))
ema5530c = request.security(syminfo.tickerid, '30', ta.ema(close, 55))
ema5530l = request.security(syminfo.tickerid, '30', ta.ema(low, 55))

ema8hourly = request.security(syminfo.tickerid, '60', ta.ema(close, 8))
ema21hourly = request.security(syminfo.tickerid, '60', ta.ema(close, 21))
ema34hourly = request.security(syminfo.tickerid, '60', ta.ema(close, 34))
ema55hourlyh = request.security(syminfo.tickerid, '60', ta.ema(high, 55))
ema55hourlyc = request.security(syminfo.tickerid, '60', ta.ema(close, 55))
ema55hourlyl = request.security(syminfo.tickerid, '60', ta.ema(low, 55))

ema8hour4 = request.security(syminfo.tickerid, '240', ta.ema(close, 8))
ema21hour4 = request.security(syminfo.tickerid, '240', ta.ema(close, 21))
ema34hour4 = request.security(syminfo.tickerid, '240', ta.ema(close, 34))
ema55hour4h = request.security(syminfo.tickerid, '240', ta.ema(high, 55))
ema55hour4c = request.security(syminfo.tickerid, '240', ta.ema(close, 55))
ema55hour4l = request.security(syminfo.tickerid, '240', ta.ema(low, 55))

ema8daily = request.security(syminfo.tickerid, 'D', ta.ema(close, 8))
ema21daily = request.security(syminfo.tickerid, 'D', ta.ema(close, 21))
ema34daily = request.security(syminfo.tickerid, 'D', ta.ema(close, 34))
ema55dailyh = request.security(syminfo.tickerid, 'D', ta.ema(high, 55))
ema55dailyc = request.security(syminfo.tickerid, 'D', ta.ema(close, 55))
ema55dailyl = request.security(syminfo.tickerid, 'D', ta.ema(low, 55))

ema8weekly = request.security(syminfo.tickerid, 'W', ta.ema(close, 8))
ema21weekly = request.security(syminfo.tickerid, 'W', ta.ema(close, 21))
ema34weekly = request.security(syminfo.tickerid, 'W', ta.ema(close, 34))
ema55weeklyh = request.security(syminfo.tickerid, 'W', ta.ema(high, 55))
ema55weeklyc = request.security(syminfo.tickerid, 'W', ta.ema(close, 55))
ema55weeklyl = request.security(syminfo.tickerid, 'W', ta.ema(low, 55))



// Plots

plot(ema34dh, title='EMA 34H', color=#00ff08, linewidth=2)
plot(ema34d, title='EMA 34C', color=#002fff, linewidth=2)
plot(ema34dl, title='EMA 34L', color=#ff0000, linewidth=2)
plot(ema200, title='EMA 200', color=#ffffff, linewidth=2)

// Stacked EMAs & Stacked Weekly EMAs Table

string  tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"])
string  tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"])
color   bullColorInput = input.color(color.new(color.green, 0), "Bullish", inline = "12")
color   bearColorInput = input.color(color.new(color.red, 0), "Bearish", inline = "12")
color   neutColorInput = input.color(color.new(color.yellow, 0), "Neutral", inline = "12")  
color   titleColorInput = input.color(color.new(color.white, 0))

    
M5EMAsLabel = string ("5")
LabelColor5 = neutColorInput
if ema85 > ema215 and ema215 > ema345 
    LabelColor5 := bullColorInput
if ema85 < ema215 and  ema215 < ema345 
    LabelColor5 := bearColorInput   
    
WaveM5EMAsLabel = string ("5")
LabelColor5wave = neutColorInput
if ema85 > ema215 and ema215 > ema345 and ema345 > ema555h
    LabelColor5wave := bullColorInput
if ema85 < ema215 and  ema215 < ema345 and ema345 < ema555l
    LabelColor5wave := bearColorInput

M15EMAsLabel = string ("15")
LabelColor15 = neutColorInput
if ema815 > ema2115 and ema2115 > ema3415 
    LabelColor15 := bullColorInput
if ema815 < ema2115 and  ema2115 < ema3415 
    LabelColor15 := bearColorInput   
    
WaveM15EMAsLabel = string ("15")
LabelColor15wave = neutColorInput
if ema815 > ema2115 and ema2115 > ema3415 and ema3415 > ema5515h
    LabelColor15wave := bullColorInput
if ema815 < ema2115 and  ema2115 < ema3415 and ema3415 < ema5515l
    LabelColor15wave := bearColorInput

M30EMAsLabel = string ("30")
LabelColor30 = neutColorInput
if ema830 > ema2130 and ema2130 > ema3430 
    LabelColor30 := bullColorInput
if ema830 < ema2130 and  ema2130 < ema3430 
    LabelColor30 := bearColorInput   
    
WaveM30EMAsLabel = string ("30")
LabelColor30wave = neutColorInput
if ema830 > ema2130 and ema2130 > ema3430 and ema3430 > ema5530h
    LabelColor30wave := bullColorInput
if ema830 < ema2130 and  ema2130 < ema3430 and ema3430 < ema5530l
    LabelColor30wave := bearColorInput    

H1EMAsLabel = string ("H1")
LabelColorHr = neutColorInput
if ema8hourly > ema21hourly and ema21hourly > ema34hourly 
    LabelColorHr := bullColorInput
if ema8hourly < ema21hourly and  ema21hourly < ema34hourly 
    LabelColorHr := bearColorInput 
    
WaveH1EMAsLabel = string ("H1")
LabelColorHrwave = neutColorInput
if ema8hourly > ema21hourly and ema21hourly > ema34hourly and ema34hourly > ema55hourlyh
    LabelColorHrwave := bullColorInput
if ema8hourly < ema21hourly and  ema21hourly < ema34hourly and ema34hourly < ema55hourlyl
    LabelColorHrwave := bearColorInput    

H4EMAsLabel = string ("H4")
LabelColorH4 = neutColorInput
if ema8hour4 > ema21hour4 and ema21hour4 > ema34hour4 
    LabelColorH4 := bullColorInput
if ema8hour4 < ema21hour4 and  ema21hour4 < ema34hour4 
    LabelColorH4 := bearColorInput
    
WaveH4EMAsLabel = string ("H4")
LabelColorH4wave = neutColorInput
if ema8hour4 > ema21hour4 and ema21hour4 > ema34hour4 and ema34hour4 > ema55hour4h
    LabelColorH4wave := bullColorInput
if ema8hour4 < ema21hour4 and  ema21hour4 < ema34hour4 and ema34hour4 < ema55hour4l
    LabelColorH4wave := bearColorInput    
    
DEMAsLabel = string ("D")
LabelColorD = neutColorInput
if ema8daily > ema21daily and ema21daily > ema34daily 
    LabelColorD := bullColorInput
if ema8daily < ema21daily and  ema21daily < ema34daily 
    LabelColorD := bearColorInput 
    
WaveDEMAsLabel = string ("D")
LabelColorDwave = neutColorInput
if ema8daily > ema21daily and ema21daily > ema34daily and ema34daily > ema55dailyh
    LabelColorDwave := bullColorInput
if ema8daily < ema21daily and  ema21daily < ema34daily and ema34daily < ema55dailyl
    LabelColorDwave := bearColorInput    
    
WEMAsLabel = string ("W")
LabelColorW = neutColorInput
if ema8weekly > ema21weekly and ema21weekly > ema34weekly 
    LabelColorW := bullColorInput
if ema8weekly < ema21weekly and  ema21weekly < ema34weekly 
    LabelColorW := bearColorInput 
    
WaveWEMAsLabel = string ("W")
LabelColorWwave = neutColorInput
if ema8weekly > ema21weekly and ema21weekly > ema34weekly and ema34weekly > ema55weeklyh
    LabelColorWwave := bullColorInput
if ema8weekly < ema21weekly and  ema21weekly < ema34weekly and ema34weekly < ema55weeklyl
    LabelColorWwave := bearColorInput



EMAsTitle = string ("EMA")
LabelColorTE = titleColorInput  

WAVETitle = string ("WAVE")
LabelColorTW = titleColorInput
    

Table = table.new(tableYposInput + "_" + tableXposInput,  columns=9, rows=2, bgcolor=color.gray)
if barstate.islast
    
    table.cell(table_id=Table, column=8, row=0, text=M5EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor5)	
    table.cell(table_id=Table, column=7, row=0, text=M15EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor15)
    table.cell(table_id=Table, column=6, row=0, text=M30EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor30)
    table.cell(table_id=Table, column=5, row=0, text=H1EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorHr)
    table.cell(table_id=Table, column=4, row=0, text=H4EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorH4)
    table.cell(table_id=Table, column=3, row=0, text=DEMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorD)
    table.cell(table_id=Table, column=2, row=0, text=WEMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorW)
    table.cell(table_id=Table, column=1, row=0, text=EMAsTitle, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorTE)   
    
    table.cell(table_id=Table, column=8, row=1, text=WaveM5EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor5wave)
    table.cell(table_id=Table, column=7, row=1, text=WaveM15EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor15wave)
    table.cell(table_id=Table, column=6, row=1, text=WaveM30EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColor30wave)
    table.cell(table_id=Table, column=5, row=1, text=WaveH1EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorHrwave)
    table.cell(table_id=Table, column=4, row=1, text=WaveH4EMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorH4wave)
    table.cell(table_id=Table, column=3, row=1, text=WaveDEMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorDwave)
    table.cell(table_id=Table, column=2, row=1, text=WaveWEMAsLabel, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorWwave)
    table.cell(table_id=Table, column=1, row=1, text=WAVETitle, height=0,text_color=color.black, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorTW)
    
    
    
    
    
    
    
    
    
    
    
    
    


