HULL Moving Average strategy

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #138421 quote
    howcar
    Participant
    New

    Hi

    I want to use the Hull MA indicator for backtesting, but cannot see any way of coding it
    to trigger a buy or sell when the color changes.

    Advice welcome.

    #138426 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Period=16
    x= 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
    MHULL=weightedaverage[ round( sqrt(Period) ) ](x)
    If MHULL > MHULL[1] and not OnMarket then
       Buy 1 contract at Market
    Endif
    If MHULL < MHULL[1] and not OnMarket then
       Sellshort 1 contract at Market
    Endif
    howcar thanked this post
    #138460 quote
    howcar
    Participant
    New

    Roberto

    Thanks for the quick reply.

    Unfortunately, I cannot get it to work.

    In case I’m doing something wrong, this is what I have done.

    1. Pasted the code into a new ‘creation by programming’ box and clicked ‘ProBacktest my system’ – There were no trades/no results.
    2. Then used EURUSD with 2 Spread – No trades.
    3. Then changed the dates to 1/6/19 – 26/6/20 – No trades.
    4. Then changed the Period to 50 – Result: Only one entry in May 2020 and exit of that trade in June 20. The trades were not at colour changes but many candles away.
      No other trades were taken for the year.
    5. Shut down the platform completely and re-opened it.
    6. Pasted the code in fresh but now I can’t get it to take any trades, whatever parameters I use.

      What I want is to have it exit on a color change and immediately open in the opposite direction because of that color change, non stop.
      With a Taking Profit parameter and Stop Loss parameter.

    As a PRT newbie, have I done anything wrong to prevent it working?

    #138461 quote
    robertogozzi
    Moderator
    Master

    Sorry, my fault on detecting colour change.

    Replace lines 4-9 with:

    If MHULL > MHULL[1] and MHULL[1]  < MHULL[2]  and not OnMarket then
       Buy 1 contract at Market
    Endif
    If If MHULL < MHULL[1] and MHULL[1]  > MHULL[2]  and not OnMarket then
       Sellshort 1 contract at Market
    Endif
    howcar thanked this post
    #138480 quote
    howcar
    Participant
    New

    Hi

    Still the same ( I deleted duplicate  if  on line 4 above, but still no joy).

    Could you also add the code for taking profit(target) and stop loss.

    Thanks

    #138482 quote
    robertogozzi
    Moderator
    Master

    You posted in ProBuilder and I did not pay attention to what you exactly wanted.

    I moved your topic to ProOrder.

    There you go:

    Defparam ComulateOrders = false
    Period=16
    x= 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
    MHULL=weightedaverage[ round( sqrt(Period) ) ](x)
    If MHULL > MHULL[1] and MHULL[1]  < MHULL[2]  and not OnMarket then
       Buy 1 contract at Market
    Endif
    If If MHULL < MHULL[1] and MHULL[1]  > MHULL[2]  and not OnMarket then
       Sellshort 1 contract at Market
    Endif
    Set Target pProfit 100
    Set Stop    pLoss   50
    #138484 quote
    howcar
    Participant
    New

    Thanks for that.

    Sorry about posting in the wrong place – what with PRT/ TRADING.PRT / PRT.CODE / PRT ANALYSIS / ProOrder  and ProBuilder!

    I had difficulty getting access last week until the helpful lady at Support told me about the existence of  PRT and TradingPRT and PRT Code and Green platforms and Blue platforms!
    She said it was a common query from customers until they got used to the differences.

    The code is now taking multiple entries and exit orders.

    But the entry/exit orders appear to be random.

    EG. I set Period = 200, on a 4HR chart. This gave a color change on 29 May, followed by the next one on 14 June

    Consequently,  there should have been one exit (from previous trade) and one new entry  on 29 May,
    and one exit and a new entry on 14 June.

    What actually occurred was 7 entries and 7 exits (ie. 7 complete trades) during this period, instead of just one single trade

    None of the trades was close to the color change.

    #138485 quote
    howcar
    Participant
    New

    Roberto

    HOLD EVERYTHING!

    Looks like my bad.

    during testing I pasted the code with Default Period 16, and didn’t change it back to 200.

     

    I will now have a strong cup of coffee, beat myself up and calmly test again much later tonight.

    I will then report the outcome to you.

     

    Thanks.

    #138493 quote
    GraHal
    Participant
    Master

    Green platforms and Blue platforms!

    Being a curious guy … I’d love to know what these Green and Blue Platforms are? 🙂

    Maybe I’ve been using PRT so long I can’t see it any more?? 🙂

    #138569 quote
    howcar
    Participant
    New

    Hi Roberto

    There is still a problem.

    To make it easier to see the problem, I set a very low Taking profit and very high Stop Loss, then ran the backtest.

    USDCHF – H4 – Period 200 – TP20 – SL 300

    Results: total 193 Trades – 180 wins(OK)   and    13 Losses(not caused by SL)

    All the high losses were caused by the trades not exiting at the color change. Instead, they all stayed open for many more bars in the next (wrong) period direction), then randomly closing.

    If you quickly run your code on a backtest you will see this, by viewing the ‘Closed Positions List’, seeing the red losses and looking at them on the chart.
    You can then see the entries have triggered but the exits didn’t, until many bars later.

    Hopefully, this will help you identify the fix.

    Thanks.

    #138570 quote
    robertogozzi
    Moderator
    Master

    It does NOT exit at a colour change because there were no provisions to!

    This version will ALWAYS be on market, since it does Stop & Reverse on a colour change:

    Defparam ComulateOrders = false
    Period=16
    x= 2*weightedaverage[round(Period/2)](close)-weightedaverage[Period](close)
    MHULL=weightedaverage[round(sqrt(Period))](x)
    If MHULL > MHULL[1] and MHULL[1] < MHULL[2] then
       Buy 1 contract at Market
    Endif
    If If MHULL < MHULL[1] and MHULL[1] > MHULL[2] then
       Sellshort 1 contract at Market
    Endif
    Set Target pProfit 100
    Set Stop    pLoss   50

    you will change your TP & SL as best fits you.

    howcar thanked this post
    #138571 quote
    GraHal
    Participant
    Master

    I got attached if it’s of any interest Period = 16, TP = 400 and SL= 100

    Spread = 4

    robertogozzi thanked this post
    #138589 quote
    howcar
    Participant
    New

    Roberto

    Just got back and tested it – Working fine.

    Thanks very much indeed.

    #138597 quote
    howcar
    Participant
    New

    GraHal

    When you go to the       ProRealtime.com         website,  it’s Blue.

    When you go to the      Trading. ProRealtime.com         website,  it’s Green.

    I had been back and forth between the two sites and hadn’t noticed it until Support pointed it out.

    #138602 quote
    Vonasi
    Moderator
    Master

    You can change the border colours in the platform settings. I used to use this feature a lot when I had three accounts so I could tell the difference between each account and demo and live for each account when I had more than one platform open at the same time. Nothing worse than thinking you just closed a demo trade for a loss and then realising it was a live trade!

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

HULL Moving Average strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
howcar @howcar Participant
Summary

This topic contains 15 replies,
has 4 voices, and was last updated by howcar
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/04/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...