# Colored Volume Bars standard deviation from mean

539 visitas
539
The colour bars:
Green: Price up - Volume > 2 x STD of last 21 bars
Blue: Price up - Volume > 1 x STD of last 21 bars
Maroon: Price down - Volume > 2 x STD of last 21 bars
Purple: Price down - Volume > 1 x STD of last 21 bars
Grey: not high volume bar
Green line: 2 bar sma
Red line: 8 period sma of the greenline
Bollinger band: 55 period sma of the 21 period sma with bands 1.618 deviation from the mean
```//
// @PVSA volume indicator -SteynTrade
//
study("Colored Volume Bars standard deviation from mean", shorttitle="Volume Deviation")
lookback=input(21)
showMA=input(true)
lengthMA1=input(2)
lengthMA2=input(8)
lengthband=input(55)

v1=volume
c1=close
o1=open

vsma1=sma(v1,lengthMA1)
vsma2=sma(vsma1,lengthMA2)
vsma3=sma(v1[lookback],lookback)
vstd=stdev(v1[lookback],lookback)

c=	iff(c1>o1 and v1>(vsma3+(2 * vstd)), green,
iff(c1>o1 and v1>(vsma3+vstd), blue,
iff(c1<o1 and v1>(vsma3+(2 * vstd)), maroon,
iff(c1<o1 and v1>(vsma3+vstd), purple, gray))))
plot(v1, style=columns, color=c)
plot(vsma1, style=line, color=green)
plot(vsma2, style=line, color=red, linewidth=2)

ma=sma(vsma1,lengthband)
offs=(1.68 * stdev(vsma1, lengthband))
up=ma+offs
dn=ma-offs
mid=(up+dn)/2
plot(showMA?up:na, color=black)
plot(showMA?dn:na, color=black)
plot(showMA?mid:na, color=blue, linewidth =2)
```