Most Power - Smooth EMA Haiken Ashi
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mostpower-app - Most Power - Smooth EMA Haiken Ashi

//@version=4
study(title = "Most Power - Smooth EMA Haiken Ashi", overlay = true)

show_ema5 = input(title = "Show EMA 5", defval = true)
show_ema10 = input(title = "Show EMA 10", defval = true)
show_ema20 = input(title = "Show EMA 20", defval = true)
show_ema50 = input(title = "Show EMA 50", defval = true)
show_ema100 = input(title = "Show EMA 100", defval = true)
show_ema200 = input(title = "Show EMA 200", defval = true)
show_ema1000 = input(title = "Show EMA 1000", defval = true)

ema5 = 5
ema10 = 10
ema20 = 20
ema50 = 50
ema100 = 100
ema200 = 200
ema1000 = 1000

haclose1 = 0.0
haopen1 = 0.0
hahigh1 = 0.0
halow1 = 0.0

haclose2 = 0.0
haopen2 = 0.0
hahigh2 = 0.0
halow2 = 0.0

haclose3 = 0.0
haopen3 = 0.0
hahigh3 = 0.0
halow3 = 0.0

haclose4 = 0.0
haopen4 = 0.0
hahigh4 = 0.0
halow4 = 0.0

haclose5 = 0.0
haopen5 = 0.0
hahigh5 = 0.0
halow5 = 0.0

haclose6 = 0.0
haopen6 = 0.0
hahigh6 = 0.0
halow6 = 0.0

haclose7 = 0.0
haopen7 = 0.0
hahigh7 = 0.0
halow7 = 0.0

o1 = ema(open, ema5)
c1 = ema(close, ema5)
h1 = ema(high, ema5)
l1 = ema(low, ema5)

o2 = ema(open, ema10)
c2 = ema(close, ema10)
h2 = ema(high, ema10)
l2 = ema(low, ema10)

o3 = ema(open, ema20)
c3 = ema(close, ema20)
h3 = ema(high, ema20)
l3 = ema(low, ema20)

o4 = ema(open, ema50)
c4 = ema(close, ema50)
h4 = ema(high, ema50)
l4 = ema(low, ema50)

o5 = ema(open, ema100)
c5 = ema(close, ema100)
h5 = ema(high, ema100)
l5 = ema(low, ema100)

o6 = ema(open, ema200)
c6 = ema(close, ema200)
h6 = ema(high, ema200)
l6 = ema(low, ema200)

o7 = ema(open, ema1000)
c7 = ema(close, ema1000)
h7 = ema(high, ema1000)
l7 = ema(low, ema1000)

haclose1 := (o1 + h1 + l1 + c1) / 4
haopen1 := na(haopen1[1]) ? (o1 + c1) / 2 : (haopen1[1] + haclose1[1]) / 2
hahigh1 := max (h1, max(haopen1, haclose1))
halow1 := min (l1, min(haopen1, haclose1))

haclose2 := (o2 + h2 + l2 + c2) / 4
haopen2 := na(haopen2[1]) ? (o2 + c2)/2 : (haopen2[1] + haclose2[1]) / 2
hahigh2 := max (h2, max(haopen2, haclose2))
halow2 := min (l2, min(haopen2, haclose2))

haclose3 := (o3 + h3 + l3 + c3) / 4
haopen3 := na(haopen3[1]) ? (o3 + c3) / 2 : (haopen3[1] + haclose3[1]) / 2
hahigh3 := max (h3, max(haopen3, haclose3))
halow3 := min (l3, min(haopen3, haclose3))

haclose4 := (o4 + h4 + l4 + c4) / 4
haopen4 := na(haopen4[1]) ? (o4 + c4) / 2 : (haopen4[1] + haclose4[1]) / 2
hahigh4 := max (h4, max(haopen4, haclose4))
halow4 := min (l4, min(haopen4, haclose4))

haclose5 := (o5 + h5 + l5 + c5) / 4
haopen5 := na(haopen5[1]) ? (o5 + c5) / 2 : (haopen5[1] + haclose5[1]) / 2
hahigh5 := max (h5, max(haopen5, haclose5))
halow5 := min (l5, min(haopen5, haclose5))

haclose6 := (o6 + h6 + l6 + c6) / 4
haopen6 := na(haopen6[1]) ? (o6 + c6) / 2 : (haopen6[1] + haclose6[1]) / 2
hahigh6 := max (h6, max(haopen6, haclose6))
halow6 := min (l6, min(haopen6, haclose6))

haclose7 := (o7 + h7 + l7 + c7) / 4
haopen7 := na(haopen7[1]) ? (o7 + c7) / 2 : (haopen7[1] + haclose7[1]) / 2
hahigh7 := max (h7, max(haopen7, haclose7))
halow7 := min (l7, min(haopen7, haclose7))

o1_1 = ema(haopen1, ema5)
c1_1 = ema(haclose1, ema5)
h1_1 = ema(hahigh1, ema5)
l1_1 = ema(halow1, ema5)

o2_2 = ema(haopen2, ema10)
c2_2 = ema(haclose2, ema10)
h2_2 = ema(hahigh2, ema10)
l2_2 = ema(halow2, ema10)

o3_3 = ema(haopen3, ema20)
c3_3 = ema(haclose3, ema20)
h3_3 = ema(hahigh3, ema20)
l3_3 = ema(halow3, ema20)

o4_4 = ema(haopen4, ema50)
c4_4 = ema(haclose4, ema50)
h4_4 = ema(hahigh4, ema50)
l4_4 = ema(halow4, ema50)

o5_5 = ema(haopen5, ema100)
c5_5 = ema(haclose5, ema100)
h5_5 = ema(hahigh5, ema100)
l5_5 = ema(halow5, ema100)

o6_6 = ema(haopen6, ema200)
c6_6 = ema(haclose6, ema200)
h6_6 = ema(hahigh6, ema200)
l6_6 = ema(halow6, ema200)

o7_7 = ema(haopen7, ema1000)
c7_7 = ema(haclose7, ema1000)
h7_7 = ema(hahigh7, ema1000)
l7_7 = ema(halow7, ema1000)

col1 = o1_1 > c1_1 ? #FFF0F5 : #F0FFF0
col2 = o2_2 > c2_2 ? #FDBCB4 : #D0F0C0
col3 = o3_3 > c3_3 ? #FF9999 : #98FF98
col4 = o4_4 > c4_4 ? #D19FE8 : #F7E98E
col5 = o5_5 > c5_5 ? #848482 : #30D5C8
col6 = o6_6 > c6_6 ? #7a0000 : #076318
col7 = o7_7 > c7_7 ? #000000 : #000000

topline1 = plot(show_ema5 ? c1_1 : na, color = col1)
botline1 = plot(show_ema5 ? o1_1: na, color = col1)
fill(botline1,topline1, color=col1, transp=0, title="Ema 5")

// SCHA 2

topline2 = plot(show_ema10 ? c2_2 : na, color = col2)
botline2 = plot(show_ema10 ? o2_2: na, color = col2)
fill(botline2,topline2, color=col2, transp=0, title="Ema 10")

topline3 = plot(show_ema20 ? c3_3 : na, color = col3)
botline3 = plot(show_ema20 ? o3_3: na, color = col3)
fill(botline3,topline3, color=col3, transp=0, title="Ema 20")

topline4 = plot(show_ema50? c4_4 : na, color = col4)
botline4 = plot(show_ema50 ? o4_4: na, color = col4)
fill(botline4,topline4, color=col4, transp=0, title="Ema 50")

topline5 = plot(show_ema100 ? c5_5 : na, color = col5)
botline5 = plot(show_ema100 ? o5_5: na, color = col5)
fill(botline5,topline5, color=col5, transp=0, title="Ema 100")

topline6 = plot(show_ema200 ? c6_6 : na, color = col6)
botline6 = plot(show_ema200 ? o6_6: na, color = col6)
fill(botline6,topline6, color=col6, transp=0, title="Ema 200")

topline7 = plot(show_ema1000 ? c7_7 : na, color = col7)
botline7 = plot(show_ema1000 ? o7_7: na, color = col7)
fill(botline7,topline7, color=col7, transp=0, title="Ema 1000")