# HMA_ATR_Bands
# Based on standard HullMovigAvg - TD Ameritrade IP Company, Inc. (c) 2008-2021
# Modified to include ATR bands by rad14733
# ATR bands can optionally be painted the same trend colors as the HMA
# v1.0 : 2021-02-22 : Initial Code
input price = close;
input length = 20;
input displace = 0;
plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
input useHMABandColors = yes;
def atr = ATR();
plot ATRupperBand = HMA + atr;
ATRupperBand.SetPaintingStrategy(PaintingStrategy.LINE);
ATRupperBand.SetDefaultColor(Color.WHITE);
ATRupperBand.AssignValueColor(if useHMABandColors then if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down") else Color.CURRENT);
ATRupperBand.SetLineWeight(1);
plot ATRlowerBand = HMA - atr;
ATRlowerBand.SetPaintingStrategy(PaintingStrategy.LINE);
ATRlowerBand.SetDefaultColor(Color.WHITE);
ATRlowerBand.AssignValueColor(if useHMABandColors then if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down") else Color.CURRENT);
ATRlowerBand.SetLineWeight(1);
#END - HMA_ATR_Bands