calculating working capital for money management
Forums › ProRealTime English forum › ProOrder support › calculating working capital for money management
- This topic has 24 replies, 3 voices, and was last updated 1 year ago by ZeroCafeine.
Tagged: capital, drawdown, equity, lotsize, management, margin, nlots, risk, size, strategyprofit
-
-
06/06/2021 at 2:30 PM #171262
ok, so (nLots*(high * Margin / 100)) wouldn’t work, but it should represent the margin value of the position size shouldn’t it?
06/06/2021 at 3:52 PM #171269Yes, it’s the total margin requirement.
Your account could have just that little money, provided your trade always stays above entry price.
1 user thanked author for this post.
06/25/2021 at 9:21 AM #172393Ciao Roberto, I was thinking of a way to vary the speed of change after some profit has accrued – what do you think of this:
123456789101112131415161718192021222324252627ONCE LotManagement = 1 //1=enable LOT size managementONCE DD = 825 //825 DrawDownONCE MyMargin = 0.5 //0.5% margin required by the brokerONCE ProfitAccrued = 0 // if strategy is stopped and restarted, insert profit or loss to date in instrument currencyDDmultiplier = 3.0 //3.0 DD multiplierif ProfitAccrued + StrategyProfit >= DD thenDDmultiplier = 2elsif ProfitAccrued + StrategyProfit >= DD*2 thenDDmultiplier = 1.5endifONCE MyCapital = ((DD * DDmultiplier) + (high * MyMargin / 100))IF IntraDayBarIndex = 0 THENMyCapital = ((DD * DDmultiplier) + (high * MyMargin / 100))ENDIFONCE MinLots = 1ONCE InitialSize = 1ONCE nLots = InitialSizeIF LotManagement THENMyEquity = MyCapital + ProfitAccrued + StrategyProfitMyInvestment = MyEquity / MyCapitalTempLot = InitialSize * MyInvestmentTempLot = round((TempLot * 10) - 0.5) / 10nLots = max(MinLots,TempLot)ENDIFDoes that look right to you? I wasn’t sure where the new code should be inserted.
06/25/2021 at 10:20 AM #172402Yes, it’s correct. It’s an interesting idea.
Another idea would be to update DrawDown at runtime. This your code with this idea embedded:
123456789101112131415161718192021222324252627282930313233343536373839ONCE LotManagement = 1 //1=enable LOT size managementONCE DD = 825 //825 DrawDownONCE MyMargin = 0.5 //0.5% margin required by the brokerONCE ProfitAccrued = 0 // if strategy is stopped and restarted, insert profit or loss to date in instrument currencyDDmultiplier = 3.0 //3.0 DD multiplierONCE MyCapital = ((DD * DDmultiplier) + (high * MyMargin / 100))// update DrawDownONCE MaxPoint = 0MyEquityx = MyCapital + ProfitAccrued + StrategyProfitMaxPoint = max(MaxPoint,MyEquityx)DDx = MaxPoint - MyEquityxDDPerCent = DDx / MaxPoint * 100DD = max(DD,DDx) //compute new DDMaxDDPerCent = DD / MaxPoint * 100 //DD percentage// end updateif ProfitAccrued + StrategyProfit >= DD thenDDmultiplier = 2elsif ProfitAccrued + StrategyProfit >= DD*2 thenDDmultiplier = 1.5endifIF IntraDayBarIndex = 0 THENMyCapital = ((DD * DDmultiplier) + (high * MyMargin / 100))ENDIFONCE MinLots = 1ONCE InitialSize = 1ONCE nLots = InitialSizeIF LotManagement THENMyEquity = MyCapital + ProfitAccrued + StrategyProfitMyInvestment = MyEquity / MyCapitalTempLot = InitialSize * MyInvestmentTempLot = round((TempLot * 10) - 0.5) / 10nLots = max(MinLots,TempLot)ENDIFYou can get rid of DD percentages, if you are planning not to use them.
06/25/2021 at 10:41 AM #172403So, 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?
06/25/2021 at 10:56 AM #172405Yes, 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.1 user thanked author for this post.
02/22/2022 at 1:04 PM #188656@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.
1234567891011121314151617181920//MONEY MANAGEMENT IIMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize = 0.2ENDIFif MM thenMinSize = 0.2 // IG minimum position size allowedMaxSize = 550 // IG tier 2 margin limitProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currencyDD = dd //MinSize drawdown in instrument currencyMultiplier = 3 //drawdown multiplierCapital = DD * MultiplierEquity = Capital + ProfitAccrued + StrategyProfitPositionSize = Max(MinSize, Equity * (MinSize/Capital))if positionsize > MaxSize thenpositionsize = MaxSizeendifPositionSize = Round(PositionSize*100)PositionSize = PositionSize/100ENDIFI 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!)
02/22/2022 at 3:51 PM #188665The 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.
1 user thanked author for this post.
02/22/2022 at 5:04 PM #188670thanks Roberto, that is more or less what i had been thinking – good to have some confirmation 😁
05/02/2023 at 1:32 PM #213984Thank 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
-
AuthorPosts
Find exclusive trading pro-tools on