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 8:00 PM #132689
I have coded after your kind help. A few queries……….
- It runs but only buys and not sells
- I would like to also add additional trades say after the initial buy ( in this case) after the RSI and initial 15/30 Hull crossover (adding to the initial trade). These additional trades would be added on every subsequent 15/30 Hull cross over on the buy side and all exit together once RSI (71) and 15/30 Hull crossover create the signal to exit the trade. So cumulative trades. Vice versa for when going short.
- I have copied and inserted the code below using the Insert PRT button……but I do not appear to be able to catch line numbers like you guys have?
-
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsif RSI[14](close) crosses under 29 thenflag = 1endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c2 = HULLa crosses over HULLbIF flag = 1 AND c2 THENBUY 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to exit long positionsif RSI[14](close) crosses over 71 thenflag = 2endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c4 = HULLa crosses under HULLbIF flag = 2 AND c4 THENSELL 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to enter short positionsif RSI[14](close) crosses over 71 thenflag = 3endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c6 = HULLa crosses under HULLbIF flag = 3 AND c6 THENSELL 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to exit short positionsif RSI[14](close) crosses under 29 thenflag = 4endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c8 = HULLa crosses over HULLbIF flag = 4 AND c8 THENBUY 1 PERPOINT AT MARKETflag = 0ENDIF
05/21/2020 at 8:01 PM #13269005/21/2020 at 9:04 PM #132699It runs but only buys and not sells
It does sell … I tested it.
Do you mean it doesn’t sellshort?
Change to below and the code will open short trades ( I tested it) …
123456789IF flag = 3 AND c6 THENSELLshort 1 PERPOINT AT MARKETflag = 0ENDIFIF flag = 4 AND c8 THENexitshort 1 PERPOINT AT MARKETflag = 0ENDIF05/21/2020 at 9:12 PM #13270005/21/2020 at 10:26 PM #132720Hi bearbull, glad to see you’ve got your code working. Just so you know, you don’t have to re-enter the Hull code every time you refer to it. Once HULLa and HULLb have been defined you can reference them anywhere in the code.
Similarly, your c4 and c6 are the same, as are c2 and c8. Once a condition is defined it can be re-used anywhere.
This won’t make any difference to the way it works, but should make the logic of it clearer.
05/22/2020 at 10:53 AM #132793GraHal thanks for that.
Unfortunately, it only SELLS now and does not BUY,
The idea is say when it sells and reaches the point where it exits (NB the exit is now the signal to go long – in the long criteria). The trade is then long until it exits which would trigger the short and so forth………………….I think i have explained it in my gibberish – LOL.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsif RSI[14](close) crosses under 29 thenflag = 1endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c2 = HULLa crosses over HULLbIF flag = 1 AND c2 THENBUY 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to exit long positionsif RSI[14](close) crosses over 71 thenflag = 2endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c4 = HULLa crosses under HULLbIF flag = 2 AND c4 THENSELL 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to enter short positionsif RSI[14](close) crosses over 71 thenflag = 3endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c6 = HULLa crosses under HULLbIF flag = 3 AND c6 THENsellshort 1 PERPOINT AT MARKETflag = 0ENDIF// Conditions to exit short positionsif RSI[14](close) crosses under 29 thenflag = 4endifPerioda= 15innera = 2*weightedaverage[round( Perioda/2)](close)-weightedaverage[Perioda](close)HULLa = weightedaverage[round(sqrt(Perioda))](innera)Periodb= 30innerb = 2*weightedaverage[round( Periodb/2)](close)-weightedaverage[Periodb](close)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c8 = HULLa crosses over HULLbIF flag = 4 AND c8 THENexitshort 1 PERPOINT AT MARKETflag = 0ENDIF05/22/2020 at 10:54 AM #13279405/22/2020 at 12:16 PM #132807https://www.prorealcode.com/documentation/cumulateorders/
The documentation found under ‘Help’ on these forums is a very useful source of information.
05/22/2020 at 12:47 PM #132809Unfortunately, it only SELLS now and does not BUY,
Hahaha it can’t sell what it has not bought! 🙂
Attached shows your code as the lower curve.
I swapped buy, sell, sellshort, exitshort and I got the upper curve.
Attached is the code for the upper curve.
05/22/2020 at 1:44 PM #132816Grahal, the two charts look like identical opposites LOL.
I will take a look on my system and see………but what a vast improvement just by looking at it. Thank you Grahal for your help.
1 user thanked author for this post.
05/22/2020 at 3:18 PM #132844Grahal,
LOL, So its now buying at the top of the RSI and selling at the bottom of the RSI………………………I want the opposite…..heh. heh……thank you for your help anyway.
SELL at top of the RSI when conditions are met and exit at the bottom of the RSI when conditions are met. Of course after the short exit at the bottom of the RSI the conditions will have met of a buy signal which then will only be closed or exited at the top of the RSI this all in conjunction of the 15/30 HULL moving average.
I trade it manually but have been thinking of programming it automatically.
05/22/2020 at 4:08 PM #132857…I want the opposite
Didn’t you have the opposite though and it was a loser on every time frame I tried it on … 5 secs to 1 hour.
What timeframe and instrument are you designing the strategy for? You have never mentioned?
I feel that Markets / Professionals are faking us … they get in early and have made their profit and are selling just about when we are thinking about buying?? So then we end up sitting on losses until the next wave / cycle??
Maybe it’s time to play them at their own game!!?? 🙂
05/22/2020 at 4:12 PM #132858So its now buying at the top of the RSI and selling at the bottom of the RSI
Maybe it just needs the values tweaking that you consider RSI top and bottom?
For example RSI 60 and 40 (instead of 79 and 21) … have you tried optimising RSI values?
05/22/2020 at 5:04 PM #132867GraHal
I like your ‘out of the box’ contrarian thinking with this. And doing the opposite seems to be working LOL.
I haven’t fiddled with the RSI, that is a good point and will take a look.
Just that I wanted to capture the up moves together with the down moves, currently only the down moves are captured.
I was using the 5000 tick time frame for smoothness, this to be applied to equities Dow, FTSE, DAX and US500 for starters.
Thanking you in advance
05/22/2020 at 5:26 PM #132873currently only the down moves are captured.
Check out the price curve against the upper equity curve … its making money during up and down trends.
And see that pink block of short only during that long down trend and 4 or 5 turqouise ( 🙂 ) blocks of Longs during the long uptrend?
I know which I’d rather put my money against? 🙂
-
AuthorPosts
Find exclusive trading pro-tools on