calculating working capital for money management

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #171262 quote
    nonetheless
    Participant
    Master

    ok, so (nLots*(high * Margin / 100)) wouldn’t work, but it should represent the margin value of the position size shouldn’t it?

    #171269 quote
    robertogozzi
    Moderator
    Master

    Yes, it’s the total margin requirement.

    Your account could have just that little money, provided your trade always stays above entry price.

    nonetheless thanked this post
    #172393 quote
    nonetheless
    Participant
    Master

    Ciao Roberto, I was thinking of a way to vary the speed of change after some profit has accrued – what do you think of this:

    ONCE LotManagement = 1          //1=enable LOT size management
    ONCE DD            = 825        //825   DrawDown
    ONCE MyMargin      = 0.5        //0.5% margin required by the broker
    ONCE ProfitAccrued = 0       // if strategy is stopped and restarted, insert profit or loss to date in instrument currency
    
    DDmultiplier = 3.0 //3.0 DD multiplier
    if ProfitAccrued + StrategyProfit >= DD then
    DDmultiplier = 2
    elsif ProfitAccrued + StrategyProfit >= DD*2 then
    DDmultiplier = 1.5
    endif
    
    ONCE MyCapital     = ((DD * DDmultiplier) + (high * MyMargin / 100)) 
    IF IntraDayBarIndex = 0 THEN
       MyCapital       = ((DD * DDmultiplier) + (high * MyMargin / 100)) 
    ENDIF
    ONCE MinLots       = 1
    ONCE InitialSize   = 1
    ONCE nLots         = InitialSize
    
    IF LotManagement THEN
       MyEquity        = MyCapital + ProfitAccrued + StrategyProfit
       MyInvestment    = MyEquity / MyCapital
       TempLot         = InitialSize * MyInvestment
       TempLot         = round((TempLot * 10) - 0.5) / 10
       nLots           = max(MinLots,TempLot)
    ENDIF

    Does that look right to you? I wasn’t sure where the new code should be inserted.

    #172402 quote
    robertogozzi
    Moderator
    Master

    Yes, it’s correct. It’s an interesting idea.

    Another idea would be to update DrawDown at runtime. This your code with this idea embedded:

    ONCE LotManagement = 1          //1=enable LOT size management
    ONCE DD            = 825        //825   DrawDown
    ONCE MyMargin      = 0.5        //0.5% margin required by the broker
    ONCE ProfitAccrued = 0       // if strategy is stopped and restarted, insert profit or loss to date in instrument currency
    
    DDmultiplier       = 3.0 //3.0 DD multiplier
    ONCE MyCapital     = ((DD * DDmultiplier) + (high * MyMargin / 100))
    
    // update DrawDown
    ONCE MaxPoint      = 0
    MyEquityx          = MyCapital + ProfitAccrued + StrategyProfit
    MaxPoint           = max(MaxPoint,MyEquityx)
    DDx                = MaxPoint - MyEquityx
    DDPerCent          = DDx / MaxPoint * 100
    DD                 = max(DD,DDx)            //compute new DD
    MaxDDPerCent       = DD / MaxPoint * 100    //DD percentage
    // end update
    
    if ProfitAccrued + StrategyProfit >= DD then
       DDmultiplier = 2
    elsif ProfitAccrued + StrategyProfit >= DD*2 then
       DDmultiplier = 1.5
    endif
    
    IF IntraDayBarIndex = 0 THEN
       MyCapital       = ((DD * DDmultiplier) + (high * MyMargin / 100)) 
    ENDIF
    
    ONCE MinLots       = 1
    ONCE InitialSize   = 1
    ONCE nLots         = InitialSize
     
    IF LotManagement THEN
       MyEquity        = MyCapital + ProfitAccrued + StrategyProfit
       MyInvestment    = MyEquity / MyCapital
       TempLot         = InitialSize * MyInvestment
       TempLot         = round((TempLot * 10) - 0.5) / 10
       nLots           = max(MinLots,TempLot)
    ENDIF

    You can get rid of DD percentages, if you are planning not to use them.

    #172403 quote
    nonetheless
    Participant
    Master

    So, this would continually monitor actual DD?

    But as positionsize increases, obviously the DD will also increase – at least proportionally. Wouldn’t that mitigate against the objective of placing larger positions in line with performance?

    #172405 quote
    robertogozzi
    Moderator
    Master

    Yes, and that would surely mitigate performances. It’s an idea for those with a geater risk aversion attitude.
    Of course it’s contrary to your idea of speeding up change as gains accrue.
    I posted it just as an idea, like many others.
    Money, Risk and Lot size management snippets, as well as those to trail SL, are a great battlefield for new ideas and tests.

    nonetheless thanked this post
    #188656 quote
    nonetheless
    Participant
    Master

    @robertogozzi, ciao Roberto, as discussed above, I’ve normally been doing backtests @ minimum positionsize and using the max drawdown as the basis for the Money Management.

    //MONEY MANAGEMENT II
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize = 0.2
    ENDIF
    if MM then
    MinSize = 0.2 // IG minimum position size allowed
    MaxSize = 550 // IG tier 2 margin limit
    ProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currency
    DD = dd  //MinSize drawdown in instrument currency
    Multiplier = 3 //drawdown multiplier
    Capital = DD * Multiplier
    Equity = Capital + ProfitAccrued + StrategyProfit
    PositionSize = Max(MinSize, Equity * (MinSize/Capital))
    if positionsize > MaxSize then
    positionsize = MaxSize
    endif
    PositionSize = Round(PositionSize*100)
    PositionSize = PositionSize/100
    ENDIF

    I have now started doing backtests with a constant exposure value, ie positionsize = 7000/close

    This gives a more accurate picture of past performance, but usually results in much higher DD

    For example, a code I’m now working on gives a DD of 400 with positionsize = 0.2, but rises to 1650 with positionsize = 7000/close

    Obviously when running live I would be starting at 0.2  (very close to 7000/close at present values).

    But which number would you use for the MM calculation — 400 or 1650 ???

    I realise that there’s no ‘right answer’ but curious to know your opinion on this, thanks.

    (or anyone else’s opinion!)

    #188665 quote
    robertogozzi
    Moderator
    Master

    The greater the number of lots, the higher the DD is, as it’s simply the exposure. If you suffer at most, say, 100 euros on Dax €1 with 1 lot, the same DD will reach 200 euros with 2 lots, etc….

    You should always use the most recent DD as displayed by PRT when you have finished optimizing with MM disabled. At that point, after coding the correct DD, you can enable MM for a final backtest before starting your code into autotrading.

    You only have to care for the initial number of lots, as each increase of that number at runtime will be consequent to a higher equity available on your account owing to accumulated profits.

    nonetheless thanked this post
    #188670 quote
    nonetheless
    Participant
    Master

    thanks Roberto, that is more or less what i had been thinking – good to have some confirmation 😁

    #213984 quote
    ZeroCafeine
    Participant
    Senior

    Thank you both for this discussion, I understood almost everything but unfortunately not really everything because my brain blocks a little bit on the 825, someone can give me a good explanation or a concrete example how do you get this number (what initial capital?, what trading instrument?, …. )

    I think that when I have a concrete example I could then try to give my opinion on the variable DDmultiply

Viewing 10 posts - 16 through 25 (of 25 total)
  • You must be logged in to reply to this topic.

calculating working capital for money management


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 24 replies,
has 3 voices, and was last updated by ZeroCafeine
2 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/06/2021
Status: Active
Attachments: No files
Logo Logo
Loading...