Multiple strategies in one strategy.
Forums › ProRealTime English forum › ProOrder support › Multiple strategies in one strategy.
- This topic has 27 replies, 8 voices, and was last updated 1 month ago by GraHal.
-
-
04/22/2018 at 4:23 PM #68931
I while back I started a thread asking if anyone ran multiple variations of the same strategy on the same instrument but with different variable settings so as to cover a broad range of settings that have worked in the past. The idea being not to put all your eggs on one setting.
https://www.prorealcode.com/topic/running-multiple-variations-of-the-same-strategy/
I just wrote a strategy with just one variable and it worked quite well in backtest with a period setting anywhere from 2 to 10. So I decided that rather than pick one setting for that variable I would check in the code all of them and if any of them met the buy or sell requirements it would place a trade. I then added a switch so that you can increase the positions size dependent on how many of the variable settings meet the entry criteria or just have level staking. I thought I’d share the code here (not the whole strategy just the multiple entry criteria being met bit of it) just in case anyone else was interested in the idea for their own strategies.
Maybe another one for your snippet library GraHal?
1234567891011121314151617181920212223242526272829303132333435363738394041a = (start of range to check)b = (end of range to check)PosSizeIncrease = 0// Set to 1 to turn on increased position sizingPositionSize = 1Flag = 0For Period = a to bIndicator1 = (indicator)[Period]Indicator2 = (indicator)[Period]IF (long entry conditions) THENFlag = Flag + 1ENDIFIF (short entry conditions) THENFlag = Flag - 1ENDIFNEXTIF PosSizeIncrease = 1 THENPositionSize = ABS(Flag)ENDIFIF Flag > 0 THENBUY PositionSize Contracts at MarketENDIFIF Flag < 0 THENSELLSHORT PositionSize Contracts at MarketENDIFIF LongOnMarket and (long exit conditions) THENSELL at marketENDIFIF ShortOnMarket and (short exit conditions) THENEXITSHORT at marketENDIF1 user thanked author for this post.
04/22/2018 at 6:54 PM #68936I posted this last year https://www.prorealcode.com/topic/multiple-strategies-within-one-trading-system/#post-41278
04/22/2018 at 7:56 PM #68938if anyone ran multiple variations of the same strategy on the same instrument but with different variable settings
Yes I do often, but then I move on and don’t follow through to refine down the best System.
I have a System running currently on Demo with 6 variations (some with added variables, e.g. volume) the v6.0 gave biggest gain by far in backtest, but up to now the v1.0 (least complex) is in the lead! I guess my System with different variables does not fit in with your criteria for different variable settings, but thought I’d mention it! 🙂
I will add your snippet Vonasi. Keep em coming and I’ll be up to 21 in no time at all! 🙂 There are 3 users in the database (link below) right now so it is increasing in popularity!
@robertogozzi your link comes up as 404 Not Found.
https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit?usp=sharing
04/22/2018 at 8:06 PM #68939Thanks for that robertogozzi. For some reason the link does not work for me but I found it here thanks to Google:
https://www.prorealcode.com/topic/multiple-strategies-within-one-trading-system/#post-41278
It is always good to link similar ideas in the same place for others to find.
Your idea is to have different strategies that an overall strategy that opens one or multiple positions depending on what set of entry criteria are hit and your code stops any more positions being traded at the same time until there are no positions – then it starts hunting for a position to open again. It would open several positions with buy or sell orders and then leave only the last strategy that opened a position to control the closing of them? As it will prioritise the last strategy over all the others you would have to put your worst strategy first and your best last in the list.
My idea was more about selecting an exact entry variable. If a period of anywhere between 2 and 10 has produced profitable results for twenty years but some years 1 is better than 10 and other 5 is the best setting for that variable then why not use them all and play the averages. Some would say that you should re-optimize every so often and use the last number that worked but I do not like this idea because just because it just worked does not mean that it will tomorrow. What if you just happen to re-optimize on the day of a market shift and 5 used to work but from today onwards 8 is the number to set your average period to?
1 user thanked author for this post.
04/22/2018 at 8:07 PM #68940I don’t know why the link doesn’t work!
04/22/2018 at 8:25 PM #68941GraHal you are doing what I have suggested as a good way to play the averages. If you have six systems that are basically the same but use six different sets of variables and all have passed backtesting with varying levels of profit then use them all – as long as they are all in a working range (i.e 2,3,4,5,6,7,8, and not 2,5,10,40). Some may win, some may lose but that is better than if you had picked just one and it turned out that it was the biggest loser going forward. The biggest limit to testing this theory out is the 25 demo strategy limit in PRT and in real life your bank account. If all six strategies are running independently it could be expensive which is why I developed my idea. All six can decide to open a position but you only open one position if PosSizeIncrease is set to zero.
It would not be too difficult to develop it further to use multiple ranges of different variables for different indicators although the more variables and the more indicators the more curve fitted so at the moment I am sticking to one.
Here is the the equity curve for my test strategy (weekly time frame) with an average period of an indicator set to open positions anywhere from 2 to 9. Unfortunately the number of trades is quite low and the drawdown more than I can stomach but it is a nice final result.
1 user thanked author for this post.
04/22/2018 at 8:26 PM #68944I don’t know why the link doesn’t work!
It is not just you mine doesn’t either……. Nicolas!
05/30/2018 at 3:54 PM #71715Hi Vonassi,
Thanks for your share.
Below a piece of code which allows to use parameters which are non consecutiveuse non-consecutive parameters1234567891011121314151617For Case = 1 to Xif Case = 1 thenPeriod1 = 10Period2 = 20elsif Case = 2 thenPeriod1 = 21Period2 = 45..elsif Case = X thenPeriod1 = 5Period2 = 8endif...Next1 user thanked author for this post.
05/30/2018 at 4:01 PM #71716I’ve added above to Snippet Library @ Row 32
1 user thanked author for this post.
05/30/2018 at 4:57 PM #71720Thanks GraHal !
One more point: I’ve observed that sometimes (quite often), when 2 different (but close variable Cases) are triggered an order at the same time or nearly (up to 2 bars), results are improved. Most probably because the current trend seems cleaner…
So have you an idea to imagine what piece of code will ONLY place an order when AT LEAST 2 cases are filled (without using a duplication of the all long conditions since only a few parameters are changing) ?
Thanks a lot in advance05/30/2018 at 5:19 PM #7172111/11/2020 at 11:20 AM #150106I am trying to implement this but struggling to figure out how to do it.
If one wanted to try different box sizes, let’s say with the ‘pure Renko’ strategy, how would you add this code to use several different box sizes in one strategy?
Thanks in advance.
pure renko code12345678910111213141516171819202122Defparam cumulateorders = falseboxSize = 40once renkoMax = ROUND(close / boxSize) * boxSizeonce renkoMin = renkoMax - boxSizeIF high > renkoMax + boxSize THENWHILE high > renkoMax + boxSizerenkoMax = renkoMax + boxSizerenkoMin = renkoMin + boxSizeWENDELSIF low < renkoMin - boxSize THENWHILE low < renkoMin - boxSizerenkoMax = renkoMax - boxSizerenkoMin = renkoMin - boxSizeWENDENDIFbuy at renkoMax + boxSize stopsellshort at renkoMin - boxSize stop11/11/2020 at 11:37 AM #15010711/11/2020 at 12:02 PM #150113I have tried a different method in one code, but it’s not beautiful – a lot of copy and paste and I’m not sure it’s the best way. I was curious about the method Vonasi mentioned here. It would be easier to analyse the results if it was all in one strategy also.
11/11/2020 at 1:26 PM #150122easier to analyse the results i
You could have different position size (0.2, 0.3, 0.4 etc) that relate to the different box size.
Then factor them up /down to position size = 1 for a direct comparison / analysis in Excel?
Just thoughts off top of my head 🙂
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on