5EMA(8,13,21,55,125) w/ EMA8-13 + EMA8-125 GC/DC Signal-by Terry
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © septeriady

//@version=5
indicator('EMA8,13 and EMA8,125 Golden / Dead Cross + BB + Supertrend', overlay=true)
// EMA Cross Indicator 


// User input: EMA lengths and source
ema_01_len = input.int(8, title='Ema 8', step=1)
ema_02_len = input.int(13, title='Ema 13', step=1)
ema_03_len = input.int(21, title='Ema 21', step=1)
ema_04_len = input.int(55, title='Ema 55', step=1)
ema_05_len = input.int(125, title='Ema 125', step=1)
ema_src = input(title='Source', defval=close)

// Perhitungan

ema_01 = ta.ema(ema_src, ema_01_len)
ema_02 = ta.ema(ema_src, ema_02_len)
ema_03 = ta.ema(ema_src, ema_03_len)
ema_04 = ta.ema(ema_src, ema_04_len)
ema_05 = ta.ema(ema_src, ema_05_len)

//EMAs in chart signs
plot(ema_01, title='ema_01', color=color.new(#E0FFFF, 0), style=plot.style_line, linewidth=1)
plot(ema_02, title='ema_02', color=color.new(#ff0040, 0), style=plot.style_line, linewidth=1)
plot(ema_03, title='ema_03', color=color.new(#00FF01, 0), style=plot.style_line, linewidth=1)
plot(ema_04, title='ema_04', color=color.new(#87CEFA, 0), style=plot.style_line, linewidth=1)
plot(ema_05, title='ema_05', color=color.new(#FAFAD2, 0), style=plot.style_line, linewidth=1)

//Cross 8-13 detect
golden_cross = ta.crossover(ema_01, ema_02)
death_cross = ta.crossunder(ema_01, ema_02)
//If cross then draw cross on ema level
plot(golden_cross or death_cross ? ema_01 : na, style=plot.style_columns, title='8-13 Cross Setting', linewidth=3, color=ema_01 > ema_02 ? color.green : color.red, transp=70)
//If cross, draw cross with text below on the chart
plotchar(golden_cross or death_cross ? ema_01 : na, title='EMA813 Crossing', char='X', location=location.bottom, color=ema_01 > ema_02 ? color.green : color.red, text='8-13', textcolor=ema_01 > ema_02 ? color.green : color.red, transp=1)

//Cross 8-125 detect
super_golden_cross = ta.crossover(ema_01, ema_05)
super_death_cross = ta.crossunder(ema_01, ema_05)
//If cross then draw cross on ema level
plot(super_golden_cross or super_death_cross ? ema_01 : na, style=plot.style_columns, title='8-125 Cross Setting', linewidth=3, color=ema_01 > ema_05 ? color.blue : color.yellow, transp=70)
//If cross, draw cross with text below on the chart
plotchar(super_golden_cross or super_death_cross ? ema_01 : na, title='EMA8125 Crossing', char='X', location=location.bottom, color=ema_01 > ema_05 ? color.blue : color.yellow, text='8-125', textcolor=ema_01 > ema_02 ? color.blue : color.yellow, transp=1)

length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#FFD700, offset = offset)
p2 = plot(lower, "Lower", color=#FFD700, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))

atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 70), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 70), fillgaps=false)