# Exponential Hull Moving Average (EHMA) for ThinkorSwim

#### skynetgen

##### Well-known member
There was a study somewhere which said that exponential hull ma is best. Here is EHMA for TOS, converted from tradingview.

Code:
``````#skynetgen
declare upper;
input length =13;
input price = close;

script ehma{
input price=close; input length=13;
#HMA = WMA(2*WMA(n/2) − WMA(n)),sqrt(n))
#EHMA = EMA(2*EMA(n/2) − EMA(n)),sqrt(n))
plot ehma =
expaverage((2 * expaverage(price, length / 2))-expaverage(price, length / 2),
round(sqrt(length)));
};

plot MVA =ehma(price,length);

MVA.DefineColor( "up", Color.UPTICK );
MVA.DefineColor( "dn", Color.DOWNTICK );
MVA.DefineColor( "def", Color.PLUM );

MVA.AssignValueColor(
if MVA > MVA[1] then MVA.Color( "up" )
else if MVA < MVA[1] then MVA.Color( "dn" )
else MVA.Color( "def" ) );``````

https://tos.mx/Z7psKFb

p.s. Dont see anything special about it. yet Another MA.

Last edited by a moderator:
Hmmm I tried to write an EHMA just from the formula. Seems it is different. Need to look at it closer, then will have more info.

Interesting. What is the formula you are using?

Could be rounding up the values. Could be I did it incorrectely.

Code:
``````# Exponential Hull Moving Avg by Horserider

input price = close;
input length = 100;
input displace = 0;

def halflength = Ceil(length / 2);
def sqrtlength = Ceil(Sqrt(length));
def val = 2 * ExpAverage(price, halflength) - ExpAverage(price, length);

plot HMA = ExpAverage(val, sqrtlength)[-displace];

HMA.SetLineWeight(2);
HMA.DefineColor("UP", Color.GREEN);
HMA.DefineColor("DOWN", Color.RED);

HMA.AssignValueColor(if HMA > HMA[1] then HMA.Color("Up") else HMA.Color("Down"));``````

Could be rounding up the values. Could be I did it incorrectely.
Well it is precisely because of rounding. all in all I dont really see anything special about either of these.

These two versions both give later signals than the regular Hull MA.

These two versions both give later signals than the regular Hull MA.
Sometimes its not about late, but about less false signals. but overall I dont really see point to use it over regular HMA, considering its already built-in into TOS and supported by default

Sometimes its not about late, but about less false signals. but overall I dont really see point to use it over regular HMA, considering its already built-in into TOS and supported by default
In the limited research I did, the late signals would have kept me out of the trade. I agree though that there is no point not to just use the TOS HMA.

87k+ Posts
358 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?