Unable to back test RSI and Hull average strategy

Viewing 15 posts - 1 through 15 (of 54 total)
  • Author
    Posts
  • #132563 quote
    bearbull
    Participant
    Average

    Hi,

    I am trying to automate a possible system I use manually and unable to back test it?…….this is a first for me. It doesn’t want to back test irrespective of the dates I insert? It uses, standard RSI indicator, 15 and 30 Hull moving averages all with 5000 tick time frame. I have attached a file of the possible system – what am I doing wrong? It sounds simple in theory but not working – I’ve obviously missed something? Sorry I’m not a programmer

    Basically, for a LONG – RSI to reach 29 or less, then confirmation of long to be 15 Hull crossing above 30 Hull……….Trade closing to be  – RSI to reach 71 or more and  15 Hull crossing below 30 Hull to close the trade, that’s it !!

    Basically, for a SHORT – RSI to reach 71 or more, then confirmation of short to be 15 Hull crossing under 30 Hull……….Trade closing to be  – RSI to reach 29 or less and  15 Hull crossing above 30 Hull to close the trade, that’s it !!

    Ideally, when in long mode, until it reaches closing ie.  the RSI to reach 71 or more and close of 15 Hull crossing below 30 Hull, I would like it to buy any subsequent 15 Hull crossing above 30 Hull on the way up adding to the original position…….same for short mode………

    Any help greatly appreciated.  Mike

    5000T.itf
    #132568 quote
    Vonasi
    Moderator
    Master

    bearbull – Welcome to the forums.

    It is much easier if you use the ‘Insert PRT Code’ button and then add the code to your post rather than expecting others to launch their platforms and then download and save your file and then import it just to see your code.

    Also always try to give your topics meaningful titles as required by the forum rules otherwise we end up with a forum full of topics all with the same title. I will edit your title.

    #132572 quote
    bearbull
    Participant
    Average

    Ok Vonasi – noted, here is the code which I have inserted via ‘Insert PRT code’ button………i hope.

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = RSI[14](close)
    c1 = (indicator1 <= 29)
    indicator2 = Average[15](close)
    indicator3 = Average[30](close)
    c2 = (indicator2 CROSSES OVER indicator3)
    
    IF c1 AND c2 THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator4 = RSI[14](close)
    c3 = (indicator4 >= 71)
    indicator5 = Average[15](close)
    indicator6 = Average[30](close)
    c4 = (indicator5 CROSSES UNDER indicator6)
    
    IF c3 AND c4 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator7 = RSI[14](close)
    c5 = (indicator7 >= 71)
    indicator8 = Average[15](close)
    indicator9 = Average[30](close)
    c6 = (indicator8 CROSSES UNDER indicator9)
    
    IF c5 AND c6 THEN
    SELLSHORT 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator10 = RSI[14](close)
    c7 = (indicator10 <= 29)
    indicator11 = Average[15](close)
    indicator12 = Average[30](close)
    c8 = (indicator11 CROSSES OVER indicator12)
    
    IF c7 AND c8 THEN
    EXITSHORT AT MARKET
    ENDIF
    #132573 quote
    GraHal
    Participant
    Master

    unable to back test it?…….this is a first for me. It doesn’t want to back test irrespective of the dates

    Do you mean you get an error message or you just get no trades when you do backtest?

    Change Crosses Over / Under for > and < and you will get attached.

    Or maybe keep the Over / Under and change the values of the RSI?

    Bull.jpg Bull.jpg
    #132577 quote
    Vonasi
    Moderator
    Master

    There is no Hull MA in your code.

    #132578 quote
    Vonasi
    Moderator
    Master

    Perhaps your conditions are never met or a trade is opened and exit conditions are never met so it is still open on the latest bar but shows as no trades..

    Run this dummy version of your strategy and you will simply see when conditions are met.

    • 1 = BUY
    • -1 = SELL
    • 2 = SELLSHORT
    • -2 = EXITSHORT
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    flag = 0
    buy 1 contract at -close limit
    
    // Conditions to enter long positions
    indicator1 = RSI[14](close)
    c1 = (indicator1 <= 29)
    indicator2 = Average[15](close)
    indicator3 = Average[30](close)
    c2 = (indicator2 CROSSES OVER indicator3)
    
    IF c1 AND c2 THEN
    //BUY 1 PERPOINT AT MARKET
    flag = 1
    ENDIF
    
    // Conditions to exit long positions
    indicator4 = RSI[14](close)
    c3 = (indicator4 >= 71)
    indicator5 = Average[15](close)
    indicator6 = Average[30](close)
    c4 = (indicator5 CROSSES UNDER indicator6)
    
    IF c3 AND c4 THEN
    //SELL AT MARKET
    flag = -1
    ENDIF
    
    // Conditions to enter short positions
    indicator7 = RSI[14](close)
    c5 = (indicator7 >= 71)
    indicator8 = Average[15](close)
    indicator9 = Average[30](close)
    c6 = (indicator8 CROSSES UNDER indicator9)
    
    IF c5 AND c6 THEN
    //SELLSHORT 1 PERPOINT AT MARKET
    flag = 2
    ENDIF
    
    // Conditions to exit short positions
    indicator10 = RSI[14](close)
    c7 = (indicator10 <= 29)
    indicator11 = Average[15](close)
    indicator12 = Average[30](close)
    c8 = (indicator11 CROSSES OVER indicator12)
    
    IF c7 AND c8 THEN
    //EXITSHORT AT MARKET
    flag = -2
    ENDIF
    
    graph flag
    #132581 quote
    nonetheless
    Participant
    Master

    If you have v11 then you can use HullAverage[15](close)

    Otherwise you need to hard code it:

    Perioda= 15
    innera = 2*weightedaverage[round( Perioda/2)](typicalprice)-weightedaverage[Perioda](typicalprice)
    HULLa = weightedaverage[round(sqrt(Perioda))](innera)
    
    Periodb= 30
    innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)
    HULLb = weightedaverage[round(sqrt(Periodb))](innerb)
    
    c2 = HULLa crosses over HULLb
    

    I tend to prefer typicalprice, (high + low + close)/3 but you can change that to (close) if you want.

    #132582 quote
    bearbull
    Participant
    Average

    Wow thank you for that prompt response.

    Prior to posting on here, I originally coded it with the ‘simplified creation‘ version of doing things, which is really cool for a novice like me, but doesnt work.

    I copied and pasted your code into a new Trading System file, after deleting the template instructions therein and leaving the form blank for your code that I inserted, but still nothing, zero results?!

    Could it possibly be the 5000 tick time frame that it doesn’t like?

    #132583 quote
    nonetheless
    Participant
    Master

    5000 ticks on the DJ is around 50 minutes. Try with 1 hour, see what you get. Most people tend to use minutes / hours etc as a TF

    #132585 quote
    bearbull
    Participant
    Average

    I am using the ProTrend  version 10.3 and when coding in the “simplified version” which I did originally,  it clearly shows the hull moving averages.

    I tried using a 1 hour time frame but still nothing? 5000 tick time frame smooths it all out coupled with the two smooth Hulls it works well. Just want to back test it over a large period.

    thanks

    #132590 quote
    Vonasi
    Moderator
    Master

    For some reason the Hull Average is shown in 10.3 strategy creation tool but it only exists in v11 and defaults to a simple moving average in v10.3.

    You will have to hard code it in your strategy using the code provided by nonetheless.

    Also as nonetheless says 5000 ticks will take barely any time at all on an instrument such as the DJI so you will need to switch to a slower time frame if you want lots of data to test on.

    The code I provided you with was a dummy strategy that takes no trades but just plots a graph to show you any time that your conditions were met. If you got a flat line at zero then your conditions were never met which will be why you got no trades.

    #132597 quote
    nonetheless
    Participant
    Master

    If the 5000 tick time frame works then just change the number of units to go further back. You’ll have at least 100k units, or 200k if you have the Premium version.

    #132613 quote
    bearbull
    Participant
    Average

    Guys thanks for your inputs and I have taken this on board. As nonetheless mentioned 5000T is around 50 mins or so.

    Nonetheless I will code those 15 and 30 Hull moving averages into Vonasi dummy code and see what happens.

    After thinking about it, in lay-mans terms  – can you advise if the programmed conditions mean that the trades will only be triggered if both the RSI and HULL cross over happen simultaneously? Hence no signals?

    I want it so the first condition RSI is met then after however long its takes (even if the RSI moves away from the original condition ) that the trade is only taken if the 15/30 Hull cross over.

    Perhaps I should get some screen shots to explain.

    Again thanks Guys, I appreciate your time

    #132622 quote
    Vonasi
    Moderator
    Master

    There is no cross over of the RSI in your code it is either above  71 or below 29 so any cross of the MA’s whilst the RSI is anywhere from 0 to 29 or 71 to 100 will be a condition met.

    If you want the RSI crossing under 29 or over 71 to be your first trigger then hold out for an MA cross no matter what the value of the RSI then you need to set a flag to show that the cross has happened.

    Something like this (long only shown):

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    if RSI[14](close) crosses under 29 then
    flag = 1
    endif
    
    indicator2 = Average[15](close)
    indicator3 = Average[30](close)
    c2 = (indicator2 CROSSES OVER indicator3)
    
    IF flag = 1 AND c2 THEN
    BUY 1 PERPOINT AT MARKET
    flag = 0
    ENDIF
    
    // Conditions to exit long positions
    
    if RSI[14](close) crosses over 71 then
    flag = 2
    endif
    
    indicator5 = Average[15](close)
    indicator6 = Average[30](close)
    c4 = (indicator5 CROSSES UNDER indicator6)
    
    IF flag = 2 AND c4 THEN
    SELL AT MARKET
    flag = 0
    ENDIF
    #132626 quote
    bearbull
    Participant
    Average

    Vonasi, you’ve hit the nail on the head!!

    Ok i will try to merge all this info together.

    Again many thanks for your help in this.

     

    Mike

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

Unable to back test RSI and Hull average strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
bearbull @bearbull Participant
Summary

This topic contains 53 replies,
has 5 voices, and was last updated by bearbull
5 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/21/2020
Status: Active
Attachments: 9 files
Logo Logo
Loading...