# Acrylic_BollingerBands
# Modified by rad14733
# Added trend indicating midLine
# Added optional cloud between bands
# Added trend indicating upper and lower bands per request from C-Note Johnson 2021-01-06
input price = close;
input displace = 0;
input length = 21;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
def sDev = stdev(data = price[-displace], length = length);
plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
MidLine.AssignValueColor(if MidLine > MidLine[1] then Color.LIME else if MidLine < MidLine[1] then Color.MAGENTA else Color.LIGHT_GRAY);
MidLine.SetLineWeight(2);
plot UpperBand = MidLine + num_Dev_Up * sDev;
UpperBand.AssignValueColor(if UpperBand > UpperBand[1] then Color.LIME else if UpperBand < UpperBand[1] then Color.MAGENTA else Color.LIGHT_GRAY);
#UpperBand.SetDefaultColor(Color.WHITE);
#UpperBand.SetDefaultColor(CreateColor(50, 150, 250));
UpperBand.SetLineWeight(2);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
LowerBand.AssignValueColor(if LowerBand > LowerBand[1] then Color.LIME else if LowerBand < LowerBand[1] then Color.MAGENTA else Color.LIGHT_GRAY);
#LowerBand.SetDefaultColor(Color.WHITE);
#LowerBand.SetDefaultColor(CreateColor(50, 150, 250));
LowerBand.SetLineWeight(2);
#AddCloud(LowerBand, UpperBand, Color.GRAY, Color.GRAY);