```
# BB_MACD Bollinger Band Indicator Watchlist
input MACD_FastLength = 12;
input MACD_SlowLength = 26;
input Length = 10;
Input Std_Dev = 1.0;
rec BB_MACD = reference MACD(fastlength = MACD_FastLength, slowlength = MACD_SlowLength, MACDlength = Length);
def avg = ExpAverage(BB_MACD, Length);
def sdev = stdev(data = BB_MACD, length = Length);
#def Lower_Band = avg - Std_Dev * sdev;
#def Upper_Band = avg + Std_Dev * sdev;
plot bbmacd = BB_MACD;
def upperband = avg + Std_Dev * sdev;
def lowerband = avg - Std_Dev * sdev;
###################################### added 09032019
BBMACD.assignValueColor(if BB_MACD > upperband then color.green else if BB_MACD < LowerBand then color.red else color.red);
#BBMACD.assignValueColor(if ( BB_MACD[1]> 0.00) then color.Green else if ( BB_MACD[1] < 0.00) then color.RED else color.RED);
input Type = PriceType.LAST;
def Lastprice =(close(priceType = Type));
assignBackgroundColor(if lastprice then color.black else color.black);#added 70419
def CurrentBar = (if !isNaN(close) and isNaN(close[-1])
then barNumber()
else double.nan); #added 090419
def LastBar = if isNaN(close[-1]) and !isNaN(close) then barNumber() else LastBar[1]; #added 100419
def priceLine = if isNan(close[-1]) and !isNAN(close) then close else priceLine[1];#added 100419
input Dec_Places = numberformat.TWO_DECIMAL_PLACES;#added 100419
```