Hull Moving Average ATR Bands for ThinkorSwim

Namor

New member
Wondering if anyone has coded the Hull Range Indicator...(it positions the ATR above and below the Hull MA -creating an envelope)?
 
@Namor I thought I had the code but am not finding it... I used to use the Hull Moving Average exclusively but switched to EMA's some months ago... Shouldn't be too difficult to code... I'll take another look because I swear I had written it last year...
 
@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

DoljF4h.png


Without HMA Trend Bands

Pa1p7mJ.png
 
Last edited:
I wrote this to create ATR bands around the closing price. You can add the Hull code in there and have it work around that.

Code:
# 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 someone make a scan out
@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

DoljF4h.png


Without HMA Trend Bands

Pa1p7mJ.png
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.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
350 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top