Unable to back test RSI and Hull average strategy
Forums › ProRealTime English forum › ProOrder support › Unable to back test RSI and Hull average strategy
- This topic has 53 replies, 5 voices, and was last updated 3 years ago by bearbull.
-
-
05/21/2020 at 11:25 AM #132563
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
05/21/2020 at 11:59 AM #132568bearbull – 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.
05/21/2020 at 12:19 PM #132572Ok Vonasi – noted, here is the code which I have inserted via ‘Insert PRT code’ button………i hope.
5000 tick, RSI, 15, 30 Hull MA strategy123456789101112131415161718192021222324252627282930313233343536373839404142434445DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = RSI[14](close)c1 = (indicator1 <= 29)indicator2 = Average[15](close)indicator3 = Average[30](close)c2 = (indicator2 CROSSES OVER indicator3)IF c1 AND c2 THENBUY 1 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator4 = RSI[14](close)c3 = (indicator4 >= 71)indicator5 = Average[15](close)indicator6 = Average[30](close)c4 = (indicator5 CROSSES UNDER indicator6)IF c3 AND c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator7 = RSI[14](close)c5 = (indicator7 >= 71)indicator8 = Average[15](close)indicator9 = Average[30](close)c6 = (indicator8 CROSSES UNDER indicator9)IF c5 AND c6 THENSELLSHORT 1 PERPOINT AT MARKETENDIF// Conditions to exit short positionsindicator10 = RSI[14](close)c7 = (indicator10 <= 29)indicator11 = Average[15](close)indicator12 = Average[30](close)c8 = (indicator11 CROSSES OVER indicator12)IF c7 AND c8 THENEXITSHORT AT MARKETENDIF05/21/2020 at 12:28 PM #132573unable 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?
05/21/2020 at 12:32 PM #13257705/21/2020 at 12:41 PM #132578Perhaps 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354DEFPARAM CumulateOrders = False // Cumulating positions deactivatedflag = 0buy 1 contract at -close limit// Conditions to enter long positionsindicator1 = 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 MARKETflag = 1ENDIF// Conditions to exit long positionsindicator4 = 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 MARKETflag = -1ENDIF// Conditions to enter short positionsindicator7 = 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 MARKETflag = 2ENDIF// Conditions to exit short positionsindicator10 = 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 MARKETflag = -2ENDIFgraph flag05/21/2020 at 12:56 PM #132581If you have v11 then you can use HullAverage[15](close)
Otherwise you need to hard code it:
123456789Perioda= 15innera = 2*weightedaverage[round( Perioda/2)](typicalprice)-weightedaverage[Perioda](typicalprice)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c2 = HULLa crosses over HULLbI tend to prefer typicalprice, (high + low + close)/3 but you can change that to (close) if you want.
05/21/2020 at 1:05 PM #132582Wow 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?
05/21/2020 at 1:16 PM #1325835000 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
05/21/2020 at 1:47 PM #132585I 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
05/21/2020 at 2:02 PM #132590For 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.
05/21/2020 at 2:10 PM #132597If 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.
05/21/2020 at 3:12 PM #132613Guys 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
05/21/2020 at 3:28 PM #132622There 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):
123456789101112131415161718192021222324252627282930DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsif RSI[14](close) crosses under 29 thenflag = 1endifindicator2 = Average[15](close)indicator3 = Average[30](close)c2 = (indicator2 CROSSES OVER indicator3)IF flag = 1 AND c2 THENBUY 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to exit long positionsif RSI[14](close) crosses over 71 thenflag = 2endifindicator5 = Average[15](close)indicator6 = Average[30](close)c4 = (indicator5 CROSSES UNDER indicator6)IF flag = 2 AND c4 THENSELL AT MARKETflag = 0ENDIF05/21/2020 at 3:51 PM #132626 -
AuthorPosts
Find exclusive trading pro-tools on