New version 18 available now

Subscription & data-feed pricing Class schedule

Margin rates Stock & option commissions

 Hull Moving Average Rate this Topic:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
brio
 Posted : Friday, February 10, 2006 11:38:23 PM
Gold Customer

Joined: 10/19/2004
Posts: 56
Guys:
I've got a challenge for you. I'm trying to write a custom indicator/PCF that will plot a 20 period
Hull Moving Average. The goal behind this type of average is to remove some of the lag inherent
in traditional moving averages. Hull defines this average as:

Integer(SquareRoot(Period)) WMA [2 x Integer(Period/2) WMA(Price)- Period WMA(Price)]
(where WMA is the weighted moving average)

He provides the Metastock formula as:
period:=Input("Period",1,200,20) ;
sqrtperiod:=Input("Square Root of Period",1,20,4);
Mov(2*(Mov(C,period/2,W))-Mov(C,period,W),sqrtperiod,W);

He also provides the SuperCharts formula as:
Input: period (Default value 20)
waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period))

Can a PCF be created for this?
If you need more info on this type of moving average, just web search: "Hull moving average."

I've been struggling with this for a while.
Any help would be greatly appreciated.

Thanks,
Vas
Bruce_L
 Posted : Saturday, February 11, 2006 8:37:51 AM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759
Please try the following as a Custom Indicator with Plot using price scale checked:

124 * C / 1155 + 92 * C1 / 525 + 4777 * C2 / 23100 + 79 * C3 / 385 + 401 * C4 / 2310 + 164 * C5 / 1155 + 17 * C6 / 154 + 13 * C7 / 165 + 109 * C8 / 2310 + 6 * C9 / 385 - 37 * C10 / 2310 - 191 * C11 / 5775 - 151 * C12 / 3850 - 4 * C13 / 105 - C14 / 30 - C15 / 35 - C16 / 42 - 2 * C17 / 105 - C18 / 70 - C19 / 105 - C20 / 210 - C21 / 525 - C22 / 2100

The same formula can be used as a Personal Criteria Formula.

You may be interested in the following:

Plotting Custom Indicators with Examples
How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
 Posted : Sunday, February 12, 2006 11:57:53 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
The Hull Moving Average is of the form:

WMA(2*WMA(C,P)-WMA(C,Q),R)

The lag of a WMA of Period P is (P-1)/3. Combining lags as described in the references below, we find that the lag of the MA is:

2*(P-1)/3-(Q-1)/3+(R-1)/3

For Q = 2*P as in the Hull MA, the lag is (R-2)/3. Notice that the inner MA:

2*WMA(C,P)-WMA(C,Q)

is a Zero-Lag MA if Q = 2*P-1. If Q = 2*P, as in the Hull MA, the lag is -1/3.

2*WMA(C,P)-WMA(WMA(C,P),P)

is a Zero-Lag MA. I do not at the moment know why the Hull MA might be preferred.

Setting up a DEMA MACD

Lag Efficient Moving Average

Thanks,
Jim Murphy
kingcambo
 Posted : Sunday, May 13, 2007 1:42:48 PM

Registered User
Joined: 3/12/2005
Posts: 32
Very cool, I have been wondering if Worden could do this. Let me ask for one other twist...is it possible to have this HULL MA turn green when prices are above, and red when prices are below?

That is how my HULL script displays in Esignal.

KingCAMBO
diceman
 Posted : Sunday, May 13, 2007 10:51:37 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
This is the only technique I know of to make an
indicator "change color" in telechart:

(not sure if you are using the blocks system)

Indicator Color, Visuals, and MACD.

Thanks
diceman
diceman
 Posted : Wednesday, December 12, 2007 8:55:49 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
"The Hull Moving Average is of the form:

WMA(2*WMA(C,P)-WMA(C,Q),R)"
-------------------------------------------------------------

bustermu

Which is the Hull length P or R?

Q is  2*P?

What is R's relationship to P,Q?

Thanks
diceman
bustermu
 Posted : Thursday, December 13, 2007 5:09:05 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (diceman)
"The Hull Moving Average is of the form:

WMA(2*WMA(C,P)-WMA(C,Q),R)"

diceman,

We can let P, Q, and R be any positive integers we please in the above moving average.  If x is a positive real number, define INT( x ) to be the integer part of x.  The above is a Hull Moving Average of Period Q if and only if:

P = INT(Q/2)

R = INT(SQR( Q ))

Why Q is called the Period, why the above relationships are imposed, and why one might prefer a Hull MA to some Zero-Lag MA, I do not yet know.

Thanks,
Jim Murphy
julian1000
 Posted : Saturday, September 14, 2013 3:07:07 PM
Registered User
Joined: 9/12/2010
Posts: 121

Hello. Could please construct this pcf for a 9 period? Thanks.

QUOTE (Bruce_L)
Please try the following as a Custom Indicator with Plot using price scale checked:

124 * C / 1155 + 92 * C1 / 525 + 4777 * C2 / 23100 + 79 * C3 / 385 + 401 * C4 / 2310 + 164 * C5 / 1155 + 17 * C6 / 154 + 13 * C7 / 165 + 109 * C8 / 2310 + 6 * C9 / 385 - 37 * C10 / 2310 - 191 * C11 / 5775 - 151 * C12 / 3850 - 4 * C13 / 105 - C14 / 30 - C15 / 35 - C16 / 42 - 2 * C17 / 105 - C18 / 70 - C19 / 105 - C20 / 210 - C21 / 525 - C22 / 2100

The same formula can be used as a Personal Criteria Formula.

You may be interested in the following:

Plotting Custom Indicators with Examples
How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!

Bruce_L
 Posted : Monday, September 16, 2013 7:58:30 AM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759

Please try the following Indicator Formula:

(81 * C + 111 * C1 + 98 * C2 + 50 * C3 + 2 * C4 - 19 * C5 - 22 * C6 - 16 * C7 - 10 * C8 - 4 * C9 - C10) / 270

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
kenjanson
 Posted : Monday, September 16, 2013 3:02:11 PM
Registered User
Joined: 12/21/2004
Posts: 35

The following formula gives percent change between 12 month price change and a front loaded, double three month plus 6 month price change calculation. The problem is when one or both elements is negative, it gives the wrong indication. For example; Front load gain 8.79, 12 month gain -32.44, Percent change returns -127.37. OR Front load gain -5.65, 12 month gain -1.84 =, Percent chande returns 206.49. Anyway around this? Here is the PCF:

((((C - C63) / (C63) * 100)*2 + ((C - C126) / (C126) * 100) - ((C - C252) / (C252) * 100)) / ((C - C252) / (C252) * 100))*100

Bruce_L
 Posted : Monday, September 16, 2013 3:44:08 PM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759

You can just subtract the two values:

100 * (2 * C / C63 + C / C126 - C / 252 - 2)

But you shouldn't try to calculate the percent change.

Calculating a percent change in something that can cross through or equal zero pretty much shouldn't be done at all. Think about it, what is the percent change from 0 to 5?

(hint, it is not 100%, think what happens when you divide by zero)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
 Posted : Tuesday, September 17, 2013 12:46:50 PM
Registered User
Joined: 10/7/2004
Posts: 1,160

Hi Bruce,

This was presented as a Hull 20-Period:

124 * C / 1155 + 92 * C1 / 525 + 4777 * C2 / 23100 + 79 * C3 / 385 + 401 * C4 / 2310 + 164 * C5 / 1155 + 17 * C6 / 154 + 13 * C7 / 165 + 109 * C8 / 2310 + 6 * C9 / 385 - 37 * C10 / 2310 - 191 * C11 / 5775 - 151 * C12 / 3850 - 4 * C13 / 105 - C14 / 30 - C15 / 35 - C16 / 42 - 2 * C17 / 105 - C18 / 70 - C19 / 105 - C20 / 210 - C21 / 525 - C22 / 2100

And, this was offered as a Hull 9-Period:

124 * C / 1155 + 92 * C1 / 525 + 4777 * C2 / 23100 + 79 * C3 / 385 + 401 * C4 / 2310 + 164 * C5 / 1155 + 17 * C6 / 154 + 13 * C7 / 165 + 109 * C8 / 2310 + 6 * C9 / 385 - 37 * C10 / 2310 - 191 * C11 / 5775 - 151 * C12 / 3850 - 4 * C13 / 105 - C14 / 30 - C15 / 35 - C16 / 42 - 2 * C17 / 105 - C18 / 70 - C19 / 105 - C20 / 210 - C21 / 525 - C22 / 2100

Yet, they both are identical.  So, I assume they are both the Hull 20-Period.

Then, later you said try this:

(81 * C + 111 * C1 + 98 * C2 + 50 * C3 + 2 * C4 - 19 * C5 - 22 * C6 - 16 * C7 - 10 * C8 - 4 * C9 - C10) / 270

Plotted on the same price chart as the Hull 20-Period, the above moves faster.  Can you please explain exactly what the above is.  Thanks, Bruce.

Bruce_L
 Posted : Tuesday, September 17, 2013 12:51:23 PM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759

The first formula in your post is the 20-Period Hull Moving Average.

The second formula in your post was not offered as a 9-Period Hull Moving Average, it is just a quote of the 20-Period Hull Moving Average in a question from julian1000 asking for a 9-Period Hull Moving Average.

The third formula in your post is in the response to that question and actually provides the 9-Period Hull Moving Average.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
 Posted : Tuesday, September 17, 2013 4:43:48 PM
Registered User
Joined: 10/7/2004
Posts: 1,160

How about PCFs for Hull 9-Period crossing up Hull 20-Period -- and also crossing down?

Bruce_L
 Posted : Wednesday, September 18, 2013 9:24:26 AM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759

The cross up would be:

40050 * C + 49038 * C1 + 32467 * C2 + 2560 * C10 + 6876 * C11 + 8154 * C12 + 7920 * C13 + 6930 * C14 + 5940 * C15 + 4950 * C16 + 3960 * C17 + 2970 * C18 + 1980 * C19 + 990 * C20 + 396 * C21 + 99 * C22 > 4160 * C3 + 34550 * C4 + 44150 * C5 + 39890 * C6 + 28700 * C7 + 17510 * C8 + 6320 * C9 AND 40050 * C1 + 49038 * C2 + 32467 * C3 + 2560 * C11 + 6876 * C12 + 8154 * C13 + 7920 * C14 + 6930 * C15 + 5940 * C16 + 4950 * C17 + 3960 * C18 + 2970 * C19 + 1980 * C20 + 990 * C21 + 396 * C22 + 99 * C23 <= 4160 * C4 + 34550 * C5 + 44150 * C6 + 39890 * C7 + 28700 * C8 + 17510 * C9 + 6320 * C10

And the cross down would be:

40050 * C + 49038 * C1 + 32467 * C2 + 2560 * C10 + 6876 * C11 + 8154 * C12 + 7920 * C13 + 6930 * C14 + 5940 * C15 + 4950 * C16 + 3960 * C17 + 2970 * C18 + 1980 * C19 + 990 * C20 + 396 * C21 + 99 * C22 < 4160 * C3 + 34550 * C4 + 44150 * C5 + 39890 * C6 + 28700 * C7 + 17510 * C8 + 6320 * C9 AND 40050 * C1 + 49038 * C2 + 32467 * C3 + 2560 * C11 + 6876 * C12 + 8154 * C13 + 7920 * C14 + 6930 * C15 + 5940 * C16 + 4950 * C17 + 3960 * C18 + 2970 * C19 + 1980 * C20 + 990 * C21 + 396 * C22 + 99 * C23 >= 4160 * C4 + 34550 * C5 + 44150 * C6 + 39890 * C7 + 28700 * C8 + 17510 * C9 + 6320 * C10

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stochastics
 Posted : Saturday, February 21, 2015 9:38:56 AM
Gold Customer

Joined: 3/3/2013
Posts: 57

Please, if you could write a PCF for the Hull 20 Xing it's own moving avg 2 in either direction.

stochastics
 Posted : Saturday, February 21, 2015 10:14:05 AM
Gold Customer

Joined: 3/3/2013
Posts: 57

Please also include the Hull 9 Xing it's own moving avg 2 in either direction.

Bruce_L
 Posted : Wednesday, February 25, 2015 1:38:05 PM

Worden Trainer

Joined: 10/7/2004
Posts: 64,759

A 20 period Hull moving average crossing through its own 2 period simple moving average in either direction can be written as follows.

SGN(2480 * C + 1568 * C1 + 729 * C2 - 37 * C3 - 730 * C4 - 730 * C5 - 730 * C6 - 730 * C7 - 730 * C8 - 730 * C9 - 730 * C10 - 394 * C11 - 142 * C12 + 26 * C13 + 110 * C14 + 110 * C15 + 110 * C16 + 110 * C17 + 110 * C18 + 110 * C19 + 110 * C20 + 66 * C21 + 33 * C22 + 11 * C23) <> SGN(2480 * C1 + 1568 * C2 + 729 * C3 - 37 * C4 - 730 * C5 - 730 * C6 - 730 * C7 - 730 * C8 - 730 * C9 - 730 * C10 - 730 * C11 - 394 * C12 - 142 * C13 + 26 * C14 + 110 * C15 + 110 * C16 + 110 * C17 + 110 * C18 + 110 * C19 + 110 * C20 + 110 * C21 + 66 * C22 + 33 * C23 + 11 * C24)

A 9 period Hull moving average crossing through its own 2 period simple moving average in either direction can be written as follows.

SGN(81 * C + 30 * C1 - 13 * C2 - 48 * C3 - 48 * C4 - 21 * C5 - 3 * C6 + 6 * C7 + 6 * C8 + 6 * C9 + 3 * C10 + C11) <> SGN(81 * C1 + 30 * C2 + -13 * C3 + -48 * C4 + -48 * C5 + -21 * C6 + -3 * C7 + 6 * C8 + 6 * C9 + 6 * C10 + 3 * C11 + C12)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

 Forum Jump Customer Training & Support - Ask a Trainer - TC2000 version 12/18 - Ask a Trainer - TC2000 version 7 - Ask a Trainer - StockFinder 5.0 - PCFs, EasyScan and Custom Indicators General Discussions - Stock and Market Talk - TC2000 version 12 or 18 - TC2000 version 7 - StockFinder 5.0 - RealCode for StockFinder 5.0 Tutorial Videos - TC2000 version 12 tutorial videos - TC2000 version 7 tutorial videos You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot delete your posts in this forum. You cannot edit your posts in this forum. You cannot create polls in this forum. You cannot vote in polls in this forum.