# 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
# Plot ATR Bands
input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);
input length = 10;
input averageType = AverageType.WILDERS;
input StopFactor = 2;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
plot line1 = close + (ATR*StopFactor);
plot line2 = close - (ATR*StopFactor);
##### End Code #####
Can you show a picture of the ATR band? and time frame? I imported your script but nothing showed up on all time frame tested. Thanks
Could you make a scan out of the code? Looks amazing!!!@Namor I went ahead and re-coded the HMA bands similar to what I tried last year... I added the ability to optionally have the bands show trend the same as the HMA itself... Hopefully, this is what you were looking for... I didn't add the ability to change the number of ATR's but it would be an easy addition if desired... Let me know what you think...
Ruby:# 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
With HMA Trend Bands
Without HMA Trend Bands
Yes you can use it in the scannerCan someone make a scan out
Could you make a scan out of the code? Looks amazing!!!
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.