HULL MA

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #114770 quote
    nonethelessnonetheless
    Participant
    Master

    Hi, I’ve been playing around with a simple trend-following code using TEMA but would prefer to have it work with the HULL MA, which is what I use for manual trading. I understand that v11 supports HullAverage[period](price) but I’m still working with v10.3 and it doesn’t recognise that syntax. How would I go about modifying the code below for Hull instead of Tema?

    Hugely grateful for any help!

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = TEMA[21](typicalPrice)
    indicator2 = TEMA[21](typicalPrice)
    c1 = (indicator1 > indicator2[1])
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = TEMA[21](typicalPrice)
    indicator4 = TEMA[21](typicalPrice)
    c2 = (indicator3 < indicator4[1])
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator5 = TEMA[21](typicalPrice)
    indicator6 = TEMA[21](typicalPrice)
    c3 = (indicator5 < indicator6[1])
    
    IF c3 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator7 = TEMA[21](typicalPrice)
    indicator8 = TEMA[21](typicalPrice)
    c4 = (indicator7 > indicator8[1])
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    #114771 quote
    GraHalGraHal
    Participant
    Legend
    indicator1 = Average[21,8](typicalPrice)

    Try above, I’ve had a few of my Systems use above successfully, but others say v10.3 doesn’t recognise Hull??

    Let us know how you go on?

    nonetheless thanked this post
    #114777 quote
    VonasiVonasi
    Moderator
    Master

    You can hard code the Hull average calculation into your strategy. Try this which has 21 period hull average based on typical price (not tested).

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    Period=21
    inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)
    
    hull = weightedaverage[round(sqrt(Period))](inner)
    
    // Conditions to enter long positions
    c1 = hull > hull[1])
    c2 = hull < hull[1])
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    
    IF c2 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    
    IF c1 THEN
    EXITSHORT AT MARKET
    ENDIF
    nonetheless thanked this post
    #114778 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    If GraHal’s suggestion doesn’t work you can use the HULL indicator in the library https://www.prorealcode.com/prorealtime-indicators/hull-moving-average/.

    #114779 quote
    nonethelessnonetheless
    Participant
    Master

    Hey, thanks for that, I’ll try it as an option. What I was really looking for though is how to hardcode a definition of the Hull MA, which I believe is something like this. I just don’t know how to make it work!

    Period=20
    inner = 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
     
    MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
     
    return MMHULL
    #114780 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Vonasi did show!

    Vonasi and nonetheless thanked this post
    #114782 quote
    nonethelessnonetheless
    Participant
    Master

    Vonasi, you are a megastar – thanks, exactly what I wanted!

    Thanks too to all others, very much appreciated!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

HULL MA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by nonethelessnonetheless
6 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/12/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...