Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Hull Moving Averages Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
billyjoeh2000
Posted : Wednesday, July 14, 2010 3:35:16 PM
Registered User
Joined: 12/2/2004
Posts: 6
Hi,
I'm looking for a Custom Indicator formula that would show a 16 day & a 36 day Hull moving avg.,  that

would show possible buy points.   Could you help me with this.  Everything I can find only talks about 

using one Hull moving avg.

Thanks,
Bill H.
Bruce_L
Posted : Wednesday, July 14, 2010 3:58:13 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Well I think you could create the 16-Period Hull Moving Average as:

(1600 * C + 2564 * C1 + 2951 * C2 + 2820 * C3 + 2230 * C4 + 1640 * C5 + 1050 * C6 + 460 * C7 - 130 * C8 - 448 * C9 - 562 * C10 - 540 * C11 - 450 * C12 - 360 * C13 - 270 * C14 - 180 * C15 - 90 * C16 - 36 * C17 - 9 * C18) / 12240

And the 36-Period Hull Moving Average as:

(11880 * C + 21006 * C1 + 27507 * C2 + 31512 * C3 + 33150 * C4 + 32550 * C5 + 29841 * C6 + 27132 * C7 + 24423 * C8 + 21714 * C9 + 19005 * C10 + 16296 * C11 + 13587 * C12 + 10878 * C13 + 8169 * C14 + 5460 * C15 + 2751 * C16 + 42 * C17 - 2667 * C18 - 4488 * C19 - 5569 * C20 - 6058 * C21 - 6103 * C22 - 5852 * C23 - 5453 * C24 - 5054 * C25 - 4655 * C26 - 4256 * C27 - 3857 * C28 - 3458 * C29 - 3059 * C30 - 2660 * C31 - 2261 * C32 - 1862 * C33 - 1463 * C34 - 1064 * C35 - 665 * C36 - 380 * C37 - 190 * C38 - 76 * C39 - 19 * C40) / 265734

That said, I do not know how you wish to combine them.

Hull Moving Average
sombody can help with hull moving avarege
Hull Moving Averages for Longer Periods
Plotting Custom Indicators with Examples
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
billyjoeh2000
Posted : Wednesday, July 14, 2010 5:25:18 PM
Registered User
Joined: 12/2/2004
Posts: 6
Hi Bruce,

What I want to do is use these two moving averages to hopefully show a better buy and sell point

when the 16 day moves up thru or down thru the 36 day MA.

The formulas work fine, but it doesn't look like it gives a better signal than a good stochastics indicator.

I'll have to do more testing and will let you know.

Thanks for your help.  

Would it be asking to much for a PCF that shows the 16 D Hull MA crossing up thru the 36 D Hull MA.

Thanks again,
Bill H.

Bruce_L
Posted : Thursday, July 15, 2010 1:40:17 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following:

(1600 * C + 2564 * C1 + 2951 * C2 + 2820 * C3 + 2230 * C4 + 1640 * C5 + 1050 * C6 + 460 * C7 - 130 * C8 - 448 * C9 - 562 * C10 - 540 * C11 - 450 * C12 - 360 * C13 - 270 * C14 - 180 * C15 - 90 * C16 - 36 * C17 - 9 * C18) / 12240 > (11880 * C + 21006 * C1 + 27507 * C2 + 31512 * C3 + 33150 * C4 + 32550 * C5 + 29841 * C6 + 27132 * C7 + 24423 * C8 + 21714 * C9 + 19005 * C10 + 16296 * C11 + 13587 * C12 + 10878 * C13 + 8169 * C14 + 5460 * C15 + 2751 * C16 + 42 * C17 - 2667 * C18 - 4488 * C19 - 5569 * C20 - 6058 * C21 - 6103 * C22 - 5852 * C23 - 5453 * C24 - 5054 * C25 - 4655 * C26 - 4256 * C27 - 3857 * C28 - 3458 * C29 - 3059 * C30 - 2660 * C31 - 2261 * C32 - 1862 * C33 - 1463 * C34 - 1064 * C35 - 665 * C36 - 380 * C37 - 190 * C38 - 76 * C39 - 19 * C40) / 265734 AND (1600 * C1 + 2564 * C2 + 2951 * C3 + 2820 * C4 + 2230 * C5 + 1640 * C6 + 1050 * C7 + 460 * C8 - 130 * C9 - 448 * C10 - 562 * C11 - 540 * C12 - 450 * C13 - 360 * C14 - 270 * C15 - 180 * C16 - 90 * C17 - 36 * C18 - 9 * C19) / 12240 <= (11880 * C1 + 21006 * C2 + 27507 * C3 + 31512 * C4 + 33150 * C5 + 32550 * C6 + 29841 * C7 + 27132 * C8 + 24423 * C9 + 21714 * C10 + 19005 * C11 + 16296 * C12 + 13587 * C13 + 10878 * C14 + 8169 * C15 + 5460 * C16 + 2751 * C17 + 42 * C18 - 2667 * C19 - 4488 * C20 - 5569 * C21 - 6058 * C22 - 6103 * C23 - 5852 * C24 - 5453 * C25 - 5054 * C26 - 4655 * C27 - 4256 * C28 - 3857 * C29 - 3458 * C30 - 3059 * C31 - 2660 * C32 - 2261 * C33 - 1862 * C34 - 1463 * C35 - 1064 * C36 - 665 * C37 - 380 * C38 - 190 * C39 - 76 * C40 - 19 * C41) / 265734

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ProgBob
Posted : Saturday, July 17, 2010 9:24:23 PM
Registered User
Joined: 7/25/2006
Posts: 19
Hi Bruce,

Is the Hull MA {HMA(n) = WMA(2*WMA(n/2) – WMA(n)),sqrt(n))} available in StockFinder?

Thanks
Robert
Bruce_L
Posted : Monday, July 19, 2010 8:36:57 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
ProgBob,
It is not one of StockFinder's built in Indicators. That said, you could replace everything after the Inherits line in the Class tab of the RealCode Editor of a RealCode Indicator with the following (you'll need to Drag and Drop it onto Price History and select Overlay with with Price History to get it in the same Pane as Price as possibly right-click on it and select Scaling | Scale With | Price History to get it in the same Scale as Price):

    Public Overrides function Plot() as System.Single
        'Hull Moving Average
        '# Period = UserInput.Integer = 21
        Plot = Single.NaN
        If isLastBar Then
            If InputCount >= Period + Period ^ .5 - 1 Then
                Dim P(3) As Integer
                P(0) = Period
                P(1) = Period / 2
                P(2) = Period ^ .5
                Dim Den(2) As Integer
                Dim Sum(2) As Single
                Dim FwSum(2) As Single
                For i As Integer = 0 To 2
                    Sum(i) = 0
                    FwSum(i) = 0
                    Den(i) = (P(i) + 1) * P(i) / 2
                Next
                Dim Past(1,P(2)) As Single
                For bar As Integer = 1 To InputCount
                    P(3) = bar Mod P(2)
                    If Bar <= P(0) Then
                        FwSum(0) += P(0) * Price.Last(InputCount - bar) - Sum(0)
                        Sum(0) += Price.Last(InputCount - bar)
                    Else
                        FwSum(0) += P(0) * Price.Last(InputCount - bar) - Sum(0)
                        Sum(0) += Price.Last(InputCount - bar) - Price.Last((InputCount - bar) + P(0))
                    End If
                    If Bar <= P(1) Then
                        FwSum(1) += P(1) * Price.Last(InputCount - bar) - Sum(1)
                        Sum(1) += Price.Last(InputCount - bar)
                    Else
                        FwSum(1) += P(1) * Price.Last(InputCount - bar) - Sum(1)
                        Sum(1) += Price.Last(InputCount - bar) - Price.Last((InputCount - bar) + P(1))
                    End If
                    If bar >= P(0) And bar <= P(0) + P(2) - 1 Then
                        FwSum(2) += P(2) * (2 * FwSum(1) / Den(1) - FwSum(0) / Den(0)) - Sum(2)
                        Sum(2) += 2 * FwSum(1) / Den(1) - FwSum(0) / Den(0)
                    End If
                    If bar > P(0) + P(2) - 1 Then
                        FwSum(2) += P(2) * (2 * FwSum(1) / Den(1) - FwSum(0) / Den(0)) - Sum(2)
                        Sum(2) += (2 * FwSum(1) / Den(1) - FwSum(0) / Den(0)) - _
                            (2 * Past(1, P(3)) / Den(1) - Past(0, P(3)) / Den(0))
                    End If
                    For i As Integer = 0 To 1
                        Past(i, P(3)) = FwSum(i)
                    Next
                    If Bar >= P(0) + P(2) - 1 Then AddToOutput(InputDate(bar - 1), FWSum(2) / Den(2))
                Next
            End If
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ProgBob
Posted : Tuesday, July 20, 2010 11:04:54 AM
Registered User
Joined: 7/25/2006
Posts: 19
Bruce,

That's exactly what I was looking for.

Thanks,
Robert
billyjoeh2000
Posted : Tuesday, July 27, 2010 3:52:00 PM
Registered User
Joined: 12/2/2004
Posts: 6
Hi Bruce,

Thanks for your PCF on Hull 16 & 36 D MA crossover.  The formula worked fine, just didn't give the good buy  or sell signals that I had hoped for. 

Thanks,
billyjoeh2000
thebull
Posted : Friday, December 31, 2010 3:56:41 PM
Registered User
Joined: 8/4/2008
Posts: 7
Bruce:

When trying to recreate the Hull Moving Average using your code above in the Realcode Editor, I get several error messages as follows:

Line 0: 'Public Overrides Function Plot() As Single' has multiple definitions with identical signatures.
Line 9: Statement cannot appear within a method body. End of method assumed.
'End Function' must be preceded by a matching 'Function'.
'End Class' must be preceded by a matching 'Class'.

Your text preceding the code references a 'Inherits line' in the 'Class tab'.  Unfortunately, I don't understand what that means.  Please help.

Victor
Bruce_L
Posted : Friday, December 31, 2010 5:28:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
thebull,
When you select Add Indicator/Condition to Chart | New RealCode Indicator, give the Indicator a name and select OK, it should bring up the RealCode Editor.

Between the area where you edit the RealCode and the area where the error messages are returned there should be two tabs. One of the tabs is Code and the other tab is Class. You need to select the Class tab.

The third line in the Class tab should start with Inherits. You need to leave this line and the two lines above it intact. Everything below the Inherits line needs to be replaced with the RealCode given in my Monday, July 19, 2010 8:36:57 AM ET post.

RealCode for Real People: Indicators

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thebull
Posted : Friday, December 31, 2010 6:38:28 PM
Registered User
Joined: 8/4/2008
Posts: 7
Bruce:

It works.  Thank you.

Victor
Bruce_L
Posted : Monday, January 3, 2011 8:21:25 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
thebull,
You're welcome.

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

Forum Jump
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.