Position Size Management – Performance based increases
Forums › ProRealTime English forum › ProOrder support › Position Size Management – Performance based increases
- This topic has 31 replies, 5 voices, and was last updated 3 months ago by JS.
Tagged: money management, position size
-
-
05/12/2017 at 6:36 PM #35351
Hi all,
I wanted to open a discussion(s) on position size management techniques. Any serious production system should have an awareness on risk. I sometimes see code attempts to dynamically adjust position size – but this is something I’d like to see more focus on here.
Generally, the better a strategy is doing, the more risk it can be allocated; and as a strategy begins to under perform, risk should be reduced and re-allocated to other strategies. If you have a library of automated trading systems running then you’d want them working together so that overall, you are dynamically shifting risk to the best performers from the worst performers.
I’d like to invite anyone to get involved here and share their ideas (code or english) on sensible position size management strategies for PRT (or indeed for any systems).
I’ll kick this off by sharing a couple of snippets.
- Average Consecutive Winning Streak based risk increment
With this risk increment system, we look at the system’s winning streaks – how many consecutive wins we get in a row. Throughout the system’s running lifespan, we continuously measure the average winning streak (average number of winning trades in a row when a streak occurs). If the current number of wins is greater than our average wining streak (AKA the system is seriously on a roll), we then increase our risk by 1 unit of measure whatever that may be. Here’s the codeConsecuitive winning streak based risk increment123456789101112131415161718192021222324252627once maxPositionSize = 10once positionSize = 1// Average Consecutive Winsonce countWins = 0once aveConsecWins = 0once countWinStreaks = 0tradeJustClosed = (longOnMarket[1] and not longOnMarket) or (shortOnMarket[1] and not shortOnMarket)lastTradeWon = positionPerf(1) > 0if tradeJustClosed and lastTradeWon thencountWins = countWins + 1 // counting the number of wins in this streakelsif tradeJustClosed and not lastTradeWon thenif countWins >= 2 then // less than 2 is not a streakcountWinStreaks = countWinStreaks + 1 // increase count of winning streakstotalWins = totalWins + countWins // total number of wins so faraveConsecWins = totalWins / countWinStreaks // average consecutivie winsendifif countWins > aveConsecWins thenpositionSize = min(maxPositionSize, positionSize + 1) // increase riskendifcountWins = 0 // we lost - reset number of wins to zeroendifgraph aveConsecWins coloured (10, 200, 10) as "ave consec wins"graph countWins// -------------------------------Note that of course you might want to monitor the consecutive losers – and if so, there would be a process for risk reduction on that basis.
- Daily, weekly or monthly performance review
With this kind of a system you look at strategy profit every so often – weekly or monthly etc. If we did well, we increase risk. If we did badly, we reduce risk. Here’s a simple implementation:Time based performance review1234567891011121314151617181920// Position size management// -- Settings --once posReviewMode = 2 // 1: weekly | 2: monthlyonce maxPositionSize = 10if usePosManagement thenonce plAtLastMonth = 0newWeek = DayOfWeek <> DayOfWeek[1] and DayOfWeek=1newMOnth = month <> month[1]doPosReview = (posReviewMode = 1 and newWeek) or (posReviewMode = 2 and newMOnth)if doPosReview thenif strategyProfit > plAtLastMonth + 1 thenpositionSize = min(maxPositionSize, positionSize + 1) // increase riskelsepositionSize = max(1, positionSize-1) // decrease riskendifplAtLastMonth = strategyProfitendifendif// *****************************************
There are many more strategies for risk management. The above hardly scrapes the surface. Let’s get a discussion going and perhaps we can end up with a few good snippets. Attached are screen shots of the above snippets.
All the best,
M
05/12/2017 at 9:06 PM #35362Great idea. The first snippet is good, but we should only allow the positionsize to increase if the average consecutive wins is calculated with at least enough trades to get a relevant average.
About the second snippet, I’m not so enthusiastic, because I know that the performance of a strategy is very often monthly, but it is a human dimension, a division of time that passes that should not affect a decision to increase its risk or not. If we think about it well, the mathematical concept has little interest in an “ordinary” strategy, but obviously it will affect profitability exponentially a strategy that is already gaining with fixed position size.
Position size management according to equity curve and statistical studies (standard deviation, ..) have already been discussed here, I’ll try to find these codes and post them here.
I’m looking forward for further interesting development here! 😉
05/12/2017 at 10:46 PM #35378The first snppet really is great and an actual enhancement to the PRT backtest suite.
Unfortunately PRT does not allow for partial close in real trading so I have not yet got around to scale in and out of trend following positions with a live system.
05/13/2017 at 7:58 AM #35384Hello,
is an interesting topic. I tried at the beginning something very easy calculate the Strategyprofit/drowdown, but this was not satisfying, if he after each trade make this.
I use now, belongs to market and strategy a system, which makes basically the same, but only every month, half year or once a year…
It is maybe not the most profitable way, but it works well and increase the outcome statically.
Adaption contract number123456789101112131415161718192021222324Gewinn = STRATEGYPROFIT//automatical contract number increasing at start of year or other time pointa=2500// maximum drawdown out of backtesting + contract price + stop reserve + 10% safety margin//2011if OpenDate = 20110101 thendyncontracts = round(Gewinn/a)ENDIFif OpenDate = 20110601 thendyncontracts = round(Gewinn/a)ENDIF//2012if OpenDate = 20120101 thendyncontracts = round(Gewinn/a)ENDIF//this is in the strategy the use number of contracts for buying and sellingcontractnumber = start contracts + dynocontracts05/15/2017 at 4:18 PM #35612@ Maz – Many thanks for your post, it is an excellent bit of useful code. I had wanted to employ this kind of management but was not proficient enough at the time to develop it.
Another way of assessing these statistics is to also look at maximum streaks – ie if in the past the streaks usually end at 5-6 then it may be an idea to actually reduce your position sizing past this point as there may be a higher probability of the streak ending. Therefore, in your example above, you would increase after 4 wins and reduce (or even go to zero) after 6 wins. Only backtesting your particular strategy would show if this proves to be more effective. This is perhaps more suited to strategies that are looking to pick the “meat” of the trade rather than squeeze out every last drop from the edges of the trend. For the latter situation of course you can still employ the above as long as you have a competent stop loss system in operation.
Also, if your strategy is one that has a reasonably high win rate, you may choose to look at the losing streaks. If they usually end at 2-3 then at your next trading signal you would increase your position by +1 as its more likely that your next trade will be a winner. Note that in this situation you would probably have to build in some sort of system cutoff (maybe at 5-6 losses) in order to avoid a scenario where the losing streak continues for a long time (thereby also creating new statistical maximums).
The better way to employ this would be perhaps to run two separate codes for long and shorts so as to not introduce anomalies that are only unique to one or the other and risk “cross-contamination” of streaks. Or you can do this within one code as long as you separate the streak calculation of the shorts from the longs. Eg so if your next signal was a long, the code would look at the long streaks section to decide how to position size etc. Again, only backtesting your strategy would show if this is of any value to consider.
All this of course (as Nicolas pointed out) relies on having a decent history and statistical data set (of streaks) so that you can rely on it effectively as your backtesting would need a reasonable number of trades and over a long time period.
Great topic, I look forward to opinions from the rest of the forum. Thanks again.
1 user thanked author for this post.
05/15/2017 at 4:28 PM #35613Another way of assessing these statistics is to also look at maximum streaks – ie if in the past the streaks usually end at 5-6 then it may be an idea to actually reduce your position sizing past this point as there may be a higher probability of the streak ending.
Exactly! Statistical distribution of the winning streak: if it exceeds, let’s say, 1 standard deviation, the position size should be reduced.
1 user thanked author for this post.
05/17/2017 at 1:37 PM #35835Here is another solution. Fixed fraction method from Ryan Jones.
When the stategyprofit exceeds a specified fraction the positionsize is increased. This increase is always measured per contract. So in this example the postionsize increases to 2 contracts at 1000 strategyprofit. Then it takes 2000 in profit (3000 in total, fraction x 2+1000) to increase to 3 contracts and so on. Of course the positionsize is decreased in the same way when the strategy is losing.
Compared with fixed ratio MM this method has the advantage to increase the positionsize faster in the beginning and slower when there is a lot of profit what is IMO superior.
Fixed fraction money management1234567891011121314151617once multiplier=1once fraction=1000once newlevel=1000once oldlevel=1000once startpositionsize=1once positionsize=startpositionsizeif strategyprofit>newlevel thenmultiplier=multiplier+1oldlevel=newlevelnewlevel=strategyprofit+multiplier*fractionpositionsize=multiplier*startpositionsizeelsif strategyprofit<oldlevel and multiplier>=2 thennewlevel=strategyprofitoldlevel=strategyprofit-multiplier*fractionmultiplier=multiplier-1positionsize=multiplier*startpositionsizeendif6 users thanked author for this post.
06/21/2017 at 3:50 PM #38756Hello, great (often underrated) topic!
Is there anyone who tried coding a percent risk model yet?
for example a long position on a €1 mini contract: position size = (x% * equity)/(risk per contract) = (x% * equity)/(last tick – stop level)
The number then should be rounded down somehow by the minimum amounts of contracts. I don’t know if it is possible to refer to the last tick in a candlestickchart to determine the risk.
Would be very helpful I suppose
06/26/2017 at 2:02 PM #39103Thanks Maz for a great topic! Great points about sizing down after a longer winning streak – the equity curve is most likely mean reverting too.
Personally I use excel to manage my position sizing so that it fits with the whole portfolio of systems I’m running and therefore I don’t use codes for sizing up or down on individual systems because that would change my overall risk (not saying that it’s a bad idea it’s just not how I do it). I use standard deviation and sharp ratio to determine which system is having the smoothest performance (I don’t like a bumpy ride). That means that I rather size up on systems with low volatility and steady performance and keeping it down on systems which may have a greater equity curve to start with but at the same time a more volatile equity curve. This method comes obviously not without problems. The past volatility doesn’t guarantee a future steady equity curve but if I recalculate it on a monthly basis I can get somewhat close to it. I think it’s important to find a method you are comfortable with and understand what the future short comings may be (ei. if you have several systems on the same market and they all starting to size up – what’s your new risk?) and before using codes to size up think what would happen if the DAX or EURUSD would dip 500 points tomorrow without your stop being executed. Even if you made some past profit to support a larger position don’t forget that you can get crushed 🙂
1 user thanked author for this post.
07/10/2017 at 3:11 PM #4026407/11/2017 at 11:53 AM #40344I’ve no problem sharing my mail but you have to ask Nicolas for my mail, think it’s part of this forum’s rule. And a little disclaimer before you get to pleased about finding a dutchman; I’m actually from Sweden. But I do live in the Netherlands.
1 user thanked author for this post.
09/14/2018 at 8:25 AM #80429Hi All, not sure if you’re already aware but if you calculate your own equity curve, you can then run the MACD indicator on the equity directly to analyse performance, which works really well apart from overshoot. (rather annoyingly) Pro order (auto trading) doesn’t allow reducing position size during a trade , which I think is allowed on manual trading. @Nicholas do you know if/when this feature will be added to Pro order? Thanks!
09/14/2018 at 8:37 AM #80436About using the equity curve and indicators on it to improve a strategy, I just wrote an article: How to improve a strategy with simulated trades – part 1
Reducing position is possible with partial closure, but still not in live trading. It will be available in a few weeks from now, hopefully.
09/14/2018 at 8:46 AM #80441Thanks Nicolas, that’s very encouraging news! Another question: when I set cumulate orders = true, the strategyprofit functions stops working (at least for me). Is there a technical reason for this? I am working on a separate calculation to work around this but it would be useful to understand if there’s a reason for strategyprofit not working with cumulate orders true… thanks 🙂 BTW I am impressed at how to proorder system is improving! I hope it keeps getting better.
09/14/2018 at 9:50 AM #80461 - Average Consecutive Winning Streak based risk increment
-
AuthorPosts