Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Hull Moving Average Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
kempferts2997
Posted : Friday, September 21, 2012 12:28:41 AM
Gold Customer Gold Customer

Joined: 12/30/2004
Posts: 45

Would someone be so kind as to put this Hull Moving Average formula, taken from SF 5, and put it into an Indicator to be used in TC200?  Thank you . . . .

'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
 

Bruce_L
Posted : Friday, September 21, 2012 8:36:34 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

It is not possible to create a generalized version as a Custom PCF Indicator, but there are numerous posts in the forums containing Indicator Formulas for Hull Moving Averages of specific periods.

Hull Moving Average
sombody can help with hull moving avarege
Hull Moving Averages for Longer Periods
Hull Moving Averages
Hull Moving Average



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