Hull moving average using data created with 9 period exponential MACD line ?

C-Note Richards

New member
Is it possible to create a Hull moving average using data created with 9 period exponential MACD line ? ThinkorSwim has the Hull moving average and it also has the MACD. If you change the MACD to use the Hull, it totally messes up the chart. I am asking if it is possible to use the data generated with the MACD 9 period to produce a hull moving average that can be displayed in green and red for up and down, respectively. Any input would be appreciated. C-Note Johnson
 
@C-Note Johnson Probably but first explain why and where the idea originated? What advantage?
My best guess is it will be another study with same information as standard MACD. Make a convincing case for your idea and I might try it.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Read this, it is a method based around Hull,..........https://www.tradingsetupsreview.com/jjrvats-price-based-trading/?utm_source=Trading+Setups+Review&utm_campaign=bb0ada6a71-RSS+Driven+Email&utm_medium=email&utm_term=0_5348f209e1-bb0ada6a71-136565649
 
Hello Thomas, I read the information at the link that you posted. It is about the Hull moving average in general. I am really interested in a very specific version of the Hull moving average. I am looking for a Hull moving average to be created using the data used to produce the MACD line.
 
Hello horserider, Sorry for the delay in getting back to the questions you posed. Life got in the way... I think the MACD is an amazing tool to determine where a stock might be headed. The MACD line is a very fast and effective VISUAL depiction to determine if price is coming into a period of convergence or divergence.

I am also convinced that the Hull moving average is better than the WMA and the EMA. It seems to be more responsive AND smoother.

To answer your question about where the idea came from. I was looking at the signal line of the MACD line, and the MACD line. This got wondering if there was a happy medium between the two lines.

I don't think the potential study will be the same information as the standard issue MACD. The reason is the signal line is an exponential moving average of the MACD line data. It is definitely not a Hull moving average of the MACD line.

Currently I use Heiken Ashi 1 day candles and a 20 period Hull moving average. This combination reveals quite a but about the potential direction of stock prices. If you can sit on your hands, you can actually make a profit !

With the standard ThinkorSwim 20 period Hull moving average, I have it programmed to go from red to green when the slope changes from negative to positive. It also changes from green to red when the slope changes from positive to negative. It is a very cool tool.

I do not think this is a waste of time. I have never seen a Hull moving average created with the data generated to create the MACD line. In turn, I think this is a novel concept to pursue.

Thank you for your consideration horseride.
 
For what it is worth, here you go.


Code:
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

input showBreakoutSignals = no;

plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);

plot Diff = Value - Avg;
plot ZeroLine = 0;

plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);



###############################
input price = close;
input length = 9;
input displace = 0;

plot HMA = MovingAverage(AverageType.HULL, diff, 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"));
 
Hello horserider, I tried it out on my charts. I think I need to tinker around with the settings to get it to work. What was your impression of the concept ? Thanks again, C-Note Johnson
 
Hello Thomas, I read the information at the link that you posted. It is about the Hull moving average in general. I am really interested in a very specific version of the Hull moving average. I am looking for a Hull moving average to be created using the data used to produce the MACD line.
C I mentioned the article as it was a tried and true tested strategy, glad you took time to look.
 
Hello horserider, I tried it out on my charts. I think I need to tinker around with the settings to get it to work. What was your impression of the concept ? Thanks again, C-Note Johnson
Ya, dont waste time, find a set up,......I read about Stockbee and Wishing wealth explored them. I have been following Stockbee for years.
 
I just found this thread and I think it's an interesting concept. I can't say that it will yield a useful result, but I can help you understand why it didn't work when you tried it.
The problem stems from the way which the HMA is calculated. In short, it requires an input which does not cross the zero line. Price data never crosses the zero line or at least we hope it doesn't! Most moving averages will work equally well for data that is offset from the zero line (the way that price data is) and also for data that crosses the zero line such as an oscillator. The macd line is an oscillator by definition so it crosses the zero line - that totally messes with the HMA moving average. The HMA can be modified so that it will work with an oscillator... If you're interested let me know and I will explain how.
 
I tried out the indicator generously posted above by @horserider, and it seems that my interpretation of the OP's request is somewhat different. @horserider's code takes a standard MACD and further smooths the histogram by using an HMA. I understood that the OP wanted to take the initial MACD crossover line and create the smoothed line using an HMA instead of an EMA. In other words, MACD consists of:
  1. A long EMA (26) subtracted from a short EMA (12)
  2. The previous line smoothed by a shorter EMA (9)
  3. The difference of line 1. and line 2., plotted as a histogram
Whereas @horserider has added a fourth step of smoothing line 3 (the histogram) with an HMA, I read the request as a desire to replace the line 2 smoothing with an HMA. The main purpose would be to make the histogram more sensitive while maintaining smoothness by using the HMA for the crossover (difference) with line 1.

Here is the code I created (by minor modification) to test the idea:

Code:
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

input showBreakoutSignals = no;

plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(AverageType.HULL, Value, MACDLength);

plot Diff = Value - Avg;
plot ZeroLine = 0;

plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

My test showed that it worked as desired, but the default settings of 12/26/9 were too erratic so I slowed down the HMA smoothing by setting the controls to 12/26/15. With this setting, it definitely gives reversal signals more quickly, sometimes by 2 or more bars, without significant false signal. Other settings may work better.

Also, my comments above about the reason why the HMA was not working in this usage were completely wrong; it works as expected (useful or not) without modification in both my and @horserider's versions.
 
Hello MoneyMagnet, I didn't realize anybody was still having fun with this idea. Did you change the code at all ? I realize you switched the parameters to 12/26/15, but is the code the same ? Take care, C-Note Johnson.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
297 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