Volume Weighted Super Guppy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pmk07
// based on Daryl Guppy Super EMA's https://www.tradingview.com/script/ViEwbRCA-CM-Super-Guppy/
//@version=4

study(title="Volume Weighted CM Super Guppy", shorttitle="VW CM SuperGuppy", overlay=true)
vol = na(volume) ? 1 : volume
src = close * vol

vema(x, length) =>
    ema(x, length)/ema(vol, length)
    
len1 = input(3, minval=1, title="Fast EMA 1")
len2 = input(6, minval=1, title="Fast EMA 2")
len3 = input(9, minval=1, title="Fast EMA 3")
len4 = input(12, minval=1, title="Fast EMA 4")
len5 = input(15, minval=1, title="Fast EMA 5")
len6 = input(18, minval=1, title="Fast EMA 6")
len7 = input(21, minval=1, title="Fast EMA 7")
len8 = input(24, minval=1, title="Slow EMA 8")
len9 = input(27, minval=1, title="Slow EMA 9")
len10 = input(30, minval=1, title="Slow EMA 10")
len11 = input(33, minval=1, title="Slow EMA 11")
len12 = input(36, minval=1, title="Slow EMA 12")
len13 = input(39, minval=1, title="Slow EMA 13")
len14 = input(42, minval=1, title="Slow EMA 14")
len15 = input(45, minval=1, title="Slow EMA 15")
len16 = input(48, minval=1, title="Slow EMA 16")
len17 = input(51, minval=1, title="Slow EMA 17")
len18 = input(54, minval=1, title="Slow EMA 18")
len19 = input(57, minval=1, title="Slow EMA 19")
len20 = input(60, minval=1, title="Slow EMA 20")
len21 = input(63, minval=1, title="Slow EMA 21")
len22 = input(66, minval=1, title="Slow EMA 22")
len23 = input(200, minval=1, title="EMA 200")

ema1 = vema(src, len1)
ema2 = vema(src, len2)
ema3 = vema(src, len3)
ema4 = vema(src, len4)
ema5 = vema(src, len5)
ema6 = vema(src, len6)
ema7 = vema(src, len7)
ema8 = vema(src, len8)
ema9 = vema(src, len9)
ema10 = vema(src, len10)
ema11 = vema(src, len11)
ema12 = vema(src, len12)
ema13 = vema(src, len13)
ema14 = vema(src, len14)
ema15 = vema(src, len15)
ema16 = vema(src, len16)
ema17 = vema(src, len17)
ema18 = vema(src, len18)
ema19 = vema(src, len19)
ema20 = vema(src, len20)
ema21 = vema(src, len21)
ema22 = vema(src, len22)
ema23 = vema(src, len23)

colfastL = (ema1 > ema2 and ema2 > ema3 and ema3 > ema4 and ema4 > ema5 and ema5 > ema6 and ema6 > ema7)
colfastS = (ema1 < ema2 and ema2 < ema3 and ema3 < ema4 and ema4 < ema5 and ema5 < ema6 and ema6 < ema7)
colslowL = ema8 > ema9 and ema9 > ema10 and ema10 > ema11 and ema11 > ema12 and ema12 > ema13 and ema13 > ema14 and ema14 > ema15 and ema15 > ema16 and ema16 > ema17 and ema17 > ema18 and ema18 > ema19 and ema19 > ema20 and ema20 > ema21 and ema21 > ema22
colslowS = ema8 < ema9 and ema9 < ema10 and ema10 < ema11 and ema11 < ema12 and ema12 < ema13 and ema13 < ema14 and ema14 < ema15 and ema15 < ema16 and ema16 < ema17 and ema17 < ema18 and ema18 < ema19 and ema19 < ema20 and ema20 < ema21 and ema21 < ema22 
colFinal = colfastL and colslowL? color.aqua : colfastS and colslowS? color.orange : color.gray
colFinal2 = colslowL  ? color.lime : colslowS ? color.red : color.gray

plot(ema1, title="Fast EMA 1", linewidth=2, color=colFinal)
plot(ema2, title="Fast EMA 2", linewidth=1, color=colFinal)
plot(ema3, title="Fast EMA 3", linewidth=1, color=colFinal)
plot(ema4, title="Fast EMA 4", linewidth=1, color=colFinal)
plot(ema5, title="Fast EMA 5", linewidth=1, color=colFinal)
plot(ema6, title="Fast EMA 6", linewidth=1, color=colFinal)
plot(ema7, title="Fast EMA 7", linewidth=2, color=colFinal)
plot(ema8, title="Slow EMA 8", linewidth=1, color=colFinal2)
plot(ema9, title="Slow EMA 9", linewidth=1, color=colFinal2)
plot(ema10, title="Slow EMA 10", linewidth=1, color=colFinal2)
plot(ema11, title="Slow EMA 11", linewidth=1, color=colFinal2)
plot(ema12, title="Slow EMA 12", linewidth=1, color=colFinal2)
plot(ema13, title="Slow EMA 13", linewidth=1, color=colFinal2)
plot(ema14, title="Slow EMA 14", linewidth=1, color=colFinal2)
plot(ema15, title="Slow EMA 15", linewidth=1, color=colFinal2)
plot(ema16, title="Slow EMA 16", linewidth=1, color=colFinal2)
plot(ema17, title="Slow EMA 17", linewidth=1, color=colFinal2)
plot(ema18, title="Slow EMA 18", linewidth=1, color=colFinal2)
plot(ema19, title="Slow EMA 19", linewidth=1, color=colFinal2)
plot(ema20, title="Slow EMA 20", linewidth=1, color=colFinal2)
plot(ema21, title="Slow EMA 21", linewidth=1, color=colFinal2)
plot(ema22, title="Slow EMA 22", linewidth=2, color=colFinal2)
plot(ema23, title="EMA 200", linewidth=2)