//@version=3
study(title="Pattern color", overlay=true)
fast = input(title="FastPeriod", type=integer, defval=25, minval=1)
slow = input(title="SlowPeriod", type=integer, defval=75, minval=1)
trans = input(title="Trans", type=integer, defval=65, minval=0, maxval=100)
FastAvg = sma(close, fast)
SlowAvg = sma(close, slow)
plot(FastAvg, color=#223a70)
plot(SlowAvg, color=red)
clr = if close >= FastAvg and FastAvg > SlowAvg
// pattern1
#0066ff
else
if FastAvg > close and close >= SlowAvg
// pattern2
#FF0000
else
if FastAvg >= SlowAvg and SlowAvg > close
// pattern3
#FF0000
else
if SlowAvg > FastAvg and FastAvg >= close
// pattern4
#FF0000
else
if SlowAvg >= close and close > FastAvg
//pattern5
#0066ff
else
if close > SlowAvg and SlowAvg >= FastAvg
// pattern6
#0066ff
else
#ffffff
bgcolor(clr, transp=trans)
study(title="Pattern color", overlay=true)
fast = input(title="FastPeriod", type=integer, defval=25, minval=1)
slow = input(title="SlowPeriod", type=integer, defval=75, minval=1)
trans = input(title="Trans", type=integer, defval=65, minval=0, maxval=100)
FastAvg = sma(close, fast)
SlowAvg = sma(close, slow)
plot(FastAvg, color=#223a70)
plot(SlowAvg, color=red)
clr = if close >= FastAvg and FastAvg > SlowAvg
// pattern1
#0066ff
else
if FastAvg > close and close >= SlowAvg
// pattern2
#FF0000
else
if FastAvg >= SlowAvg and SlowAvg > close
// pattern3
#FF0000
else
if SlowAvg > FastAvg and FastAvg >= close
// pattern4
#FF0000
else
if SlowAvg >= close and close > FastAvg
//pattern5
#0066ff
else
if close > SlowAvg and SlowAvg >= FastAvg
// pattern6
#0066ff
else
#ffffff
bgcolor(clr, transp=trans)