7EMA_6MA + Fill EMA++
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Andrey Semenov


//@version=4
study("7EMA_6MA + Fill EMA++" , overlay=true)

// INPUT
e1 = input(title="EMA-1", type=input.integer, defval=5)
e2 = input(title="EMA-2", type=input.integer, defval=10)
e3 = input(title="EMA-3", type=input.integer, defval=20)
e4 = input(title="EMA-4", type=input.integer, defval=50)
e5 = input(title="EMA-5", type=input.integer, defval=100)
e6 = input(title="EMA-6", type=input.integer, defval=200)
e7 = input(title="EMA-7", type=input.integer, defval=150)

S1 = input(title="MA-1", type=input.integer, defval=5)
S2 = input(title="MA-2", type=input.integer, defval=10)
S3 = input(title="MA-3", type=input.integer, defval=20)
S4 = input(title="MA-4", type=input.integer, defval=50)
S5 = input(title="MA-5", type=input.integer, defval=100)
S6 = input(title="MA-6", type=input.integer, defval=200)



// FIX ema/ma
res1 = input(title="EMA-1 fix at", type=input.resolution, defval="")
res2 = input(title="EMA-2 fix at", type=input.resolution, defval="")
res3 = input(title="EMA-3 fix at", type=input.resolution, defval="")
res4 = input(title="EMA-4 fix at", type=input.resolution, defval="")
res5 = input(title="EMA-5 fix at", type=input.resolution, defval="")
res6 = input(title="EMA-6 fix at", type=input.resolution, defval="")
res7 = input(title="EMA-7 fix at", type=input.resolution, defval="")

resS1 = input(title="MA-1 fix at", type=input.resolution, defval="")
resS2 = input(title="MA-2 fix at", type=input.resolution, defval="")
resS3 = input(title="MA-3 fix at", type=input.resolution, defval="")
resS4 = input(title="MA-4 fix at", type=input.resolution, defval="")
resS5 = input(title="MA-5 fix at", type=input.resolution, defval="")
resS6 = input(title="MA-6 fix at", type=input.resolution, defval="")


// VIEWING ema/ma on screen
on1 = input(title="EMA-1", type=input.bool, defval=true)
on2 = input(title="EMA-2", type=input.bool, defval=true)
on3 = input(title="EMA-3", type=input.bool, defval=true)
on4 = input(title="EMA-4", type=input.bool, defval=true)
on5 = input(title="EMA-5", type=input.bool, defval=true)
on6 = input(title="EMA-6", type=input.bool, defval=true)
on7 = input(title="EMA-7", type=input.bool, defval=false)

onS1 = input(title="MA-1", type=input.bool, defval=false)
onS2 = input(title="MA-2", type=input.bool, defval=false)
onS3 = input(title="MA-3", type=input.bool, defval=false)
onS4 = input(title="MA-4", type=input.bool, defval=false)
onS5 = input(title="MA-5", type=input.bool, defval=false)
onS6 = input(title="MA-6", type=input.bool, defval=true)



// EMAs
ema1 = on1 ? security(syminfo.tickerid, res1, ema(close,e1), barmerge.gaps_on, barmerge.lookahead_off) : na
ema2 = on2 ? security(syminfo.tickerid, res2, ema(close,e2), barmerge.gaps_on, barmerge.lookahead_off) : na
ema3 = on3 ? security(syminfo.tickerid, res3, ema(close,e3), barmerge.gaps_on, barmerge.lookahead_off) : na
ema4 = on4 ? security(syminfo.tickerid, res4, ema(close,e4), barmerge.gaps_on, barmerge.lookahead_off) : na
ema5 = on5 ? security(syminfo.tickerid, res5, ema(close,e5), barmerge.gaps_on, barmerge.lookahead_off) : na
ema6 = on6 ? security(syminfo.tickerid, res6, ema(close,e6), barmerge.gaps_on, barmerge.lookahead_off) : na
ema7 = on7 ? security(syminfo.tickerid, res7, ema(close,e7), barmerge.gaps_on, barmerge.lookahead_off) : na


// SMAs
sma1 = onS1 ? security(syminfo.tickerid, resS1, sma(close,S1), barmerge.gaps_on, barmerge.lookahead_off) : na
sma2 = onS2 ? security(syminfo.tickerid, resS2, sma(close,S2), barmerge.gaps_on, barmerge.lookahead_off) : na
sma3 = onS3 ? security(syminfo.tickerid, resS3, sma(close,S3), barmerge.gaps_on, barmerge.lookahead_off) : na
sma4 = onS4 ? security(syminfo.tickerid, resS4, sma(close,S4), barmerge.gaps_on, barmerge.lookahead_off) : na
sma5 = onS5 ? security(syminfo.tickerid, resS5, sma(close,S5), barmerge.gaps_on, barmerge.lookahead_off) : na
sma6 = onS6 ? security(syminfo.tickerid, resS6, sma(close,S6), barmerge.gaps_on, barmerge.lookahead_off) : na

//COLOR FOR EMA/MA
ema1plot = plot(ema1, title = "EMA-1", color = #787b86)
ema2plot = plot(ema2, title = "EMA-2", color = #66bb6a)
ema3plot = plot(ema3, title = "EMA-3", color = #42a5f5)
ema4plot = plot(ema4, title = "EMA-4", color = #f44336)
plot(ema5, title = "EMA-5", color = #ab47bc)
plot(ema6, title = "EMA-6", color = #ffa726)
plot(ema7, title = "EMA-7", color = #ffa726)

plot(sma1, title = "MA-1", color = #7e57c2)
plot(sma2, title = "MA-2", color = #26c6da)
plot(sma3, title = "MA-3", color = #26c6da)
plot(sma4, title = "MA-4", color = #26c6da)
plot(sma5, title = "MA-5", color = #26c6da)
plot(sma6, title = "MA-6", color = #000000)



//Fill
fill(ema1plot, ema2plot, color=ema1>ema2? color.rgb(0,150,0,75):color.rgb(250,0,0,75), title="Fill Cloud EMA-1/EMA-2", editable=true)
fill(ema2plot, ema3plot, color=ema2>ema3? color.rgb(0,150,0,75):color.rgb(250,0,0,75), title="Fill Cloud EMA-2/EMA-3", editable=true)
fill(ema3plot, ema4plot, color=ema3>ema4? color.rgb(0,150,0,75):color.rgb(250,0,0,75), title="Fill Cloud EMA-3/EMA-4", editable=true)

