Position Size Management – Performance based increases

Viewing 15 posts - 1 through 15 (of 32 total)
  • Author
    Posts
  • #35351 quote
    Maz
    Participant
    Veteran

    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.

    1. 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 code

      once maxPositionSize = 10
      once positionSize = 1
      
      // Average Consecutive Wins
      once countWins = 0
      once aveConsecWins = 0
      once countWinStreaks = 0
      
      tradeJustClosed = (longOnMarket[1] and not longOnMarket) or (shortOnMarket[1] and not shortOnMarket)
      lastTradeWon    = positionPerf(1) > 0
      
      if tradeJustClosed and lastTradeWon then
      countWins = countWins + 1 // counting the number of wins in this streak
      elsif tradeJustClosed and not lastTradeWon then
      if countWins >= 2 then // less than 2 is not a streak
      countWinStreaks = countWinStreaks + 1 // increase count of winning streaks
      totalWins = totalWins + countWins // total number of wins so far
      aveConsecWins = totalWins / countWinStreaks // average consecutivie wins
      endif
      if countWins > aveConsecWins then
      positionSize = min(maxPositionSize, positionSize + 1) // increase risk
      endif
      countWins = 0 // we lost - reset number of wins to zero
      endif
      graph 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.

    2. 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:

      // Position size management
      // -- Settings --
      once posReviewMode   = 2 // 1: weekly | 2: monthly
      once maxPositionSize = 10
      
      if usePosManagement then
      once plAtLastMonth = 0
      newWeek  = DayOfWeek <> DayOfWeek[1] and DayOfWeek=1
      newMOnth = month <> month[1]
      doPosReview = (posReviewMode = 1 and newWeek) or (posReviewMode = 2 and newMOnth)
      if doPosReview then
      if strategyProfit > plAtLastMonth + 1  then
      positionSize = min(maxPositionSize, positionSize + 1) // increase risk
      else
      positionSize = max(1, positionSize-1) // decrease risk
      endif
      plAtLastMonth = strategyProfit
      endif
      endif
      // *****************************************

     

    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

    manel, Inertia, Cosmic1 and 4 others thanked this post
    #35362 quote
    Nicolas
    Keymaster
    Master

    Great 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! 😉

    #35378 quote
    Derek
    Participant
    Veteran

    The 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.

    #35384 quote
    wreini1982
    Participant
    Junior

    Hello,

    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.

    Gewinn = STRATEGYPROFIT
    
    //automatical contract number increasing at start of year or other time point
    
    a=2500
    // maximum drawdown out of backtesting + contract price + stop reserve + 10% safety margin
    
    //2011
    if OpenDate = 20110101 then
    dyncontracts = round(Gewinn/a)
    ENDIF
    
    if OpenDate = 20110601 then
    dyncontracts = round(Gewinn/a)
    ENDIF
    
    //2012
    if OpenDate = 20120101 then
    dyncontracts = round(Gewinn/a)
    ENDIF
    
    //this is in the strategy the use number of contracts for buying and selling
    
    contractnumber = start contracts + dynocontracts
    #35612 quote
    manel
    Participant
    Veteran

    @ 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.

    Maz thanked this post
    #35613 quote
    Nicolas
    Keymaster
    Master

    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.

    Exactly! Statistical distribution of the winning streak: if it exceeds, let’s say, 1 standard deviation, the position size should be reduced.

    Brad thanked this post
    #35835 quote
    Despair
    Blocked
    Master

    Here 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.

     

    once multiplier=1
    once fraction=1000
    once newlevel=1000
    once oldlevel=1000
    once startpositionsize=1
    once positionsize=startpositionsize
    if strategyprofit>newlevel then
      multiplier=multiplier+1
      oldlevel=newlevel
      newlevel=strategyprofit+multiplier*fraction
      positionsize=multiplier*startpositionsize
    elsif strategyprofit<oldlevel and multiplier>=2 then
      newlevel=strategyprofit
      oldlevel=strategyprofit-multiplier*fraction
      multiplier=multiplier-1
      positionsize=multiplier*startpositionsize
    endif
    Maz, Cosmic1, victormork and 3 others thanked this post
    #38756 quote
    Seb
    Participant
    Average

    Hello, 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

    #39103 quote
    victormork
    Participant
    Veteran

    Thanks 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 🙂

    EB thanked this post
    #40264 quote
    Seb
    Participant
    Average

    Hi Victor, would you mind sharing your e-mail? Would be nice to exchange trading experiences with a fellow Dutchman.

    #40344 quote
    victormork
    Participant
    Veteran

    I’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.

    Seb thanked this post
    #80429 quote
    buffster76
    Participant
    Average

    Hi 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!

    #80436 quote
    Nicolas
    Keymaster
    Master

    About 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.

    #80441 quote
    buffster76
    Participant
    Average

    Thanks 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.

    #80461 quote
    Nicolas
    Keymaster
    Master

    Yes, ProOrder keeps getting better because you people are helping to improve it 😉

    STRATEGYPROFIT is calculated with closed orders only, but with the ones that are still on market.

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

Position Size Management – Performance based increases


ProOrder support

New Reply
Author
author-avatar
Maz @eqmaz Participant
Summary

This topic contains 31 replies,
has 5 voices, and was last updated by JS
1 year, 5 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 05/12/2017
Status: Active
Attachments: 2 files
Logo Logo
Loading...