Reinvesting full value of portfolio after each trade

Forums ProRealTime English forum ProOrder support Reinvesting full value of portfolio after each trade

Viewing 12 posts - 1 through 12 (of 12 total)
  • #122206

    Hello everyone!

    I have been playing around with the following code in regards to reinvesting for my tradingsystem (I found the code somewhere here on the forum):

    And when for orders:

    However I have a problem, when I enter starting capital to lets say 10000 I get a return of 12000 for my system

    And when I enter capital as 100000 I still get the return  of 2000 (102000)

    For the record I also change the sum “initial capital” to the right of the code itself

     

    Maybe Im barking up the wrong tree here but Im looking for code that always reinvests 100% (or as close as possible to 100%) of my portfolio value at each trade..

     

    Does anyone know where I have gone wrong and/or which adjustments I could try?

    Thank you in advance!

    #122207

    Can the position size of your chosen market increase by fractions (1.1, 1.2. 1.3 etc) or is position size limited to integers (1,2,3 etc)?

    #122220

    What do you mean by “I get a return of 12000 for my system”?

    If the STRATEGYPROFIT is equal to 2000, your equity variable is equal to 10.000 + 2000 = 12.000

    #122221

    You can’t invest 100% of your money because you need to keep some to cover margin otherwise you will get a margin call.

    To calculate position size for 100% you would need to divide your equity by the price of what you are buying and buy that number of shares/contracts.

    #122308

    This is the Money Management i use. It’s based on the margin cost and is fully adjustable as to how much profit you want to reinvest. This is set up for the DOW and it works up to the IG 2nd margin tier, should you be so lucky as to ever get up there.

    If you set your startpositionsize based on how much of your working capital you want to use, then this will handle the strategyprofit part. You could conceivably reinvest 100% of strategyprofit but if your margin is 100% of total equity, you’ll get a margin call as soon as it moves against you.  ‘Factor’ is the variable that controls the percentage of strategyprofit. It actually works as a divisor, so it’s an inverse relation — higher the factor, lower percentage reinvested.

    You will also need to check what leverage is offered for the instrument you are trading and the max position for each tier.

     

    1 user thanked author for this post.
    #122311

    Whose code is above @nonetheless so I can credit them as being the Author in the Snippet Library … or are you now a  Coding Wizard!? 🙂

    I would add as Nonetheless (Author) or Author (N0netheless) in the Library.

    Maybe it is from the Snippet Library anyway so I need not bother?

    #122315

    Whose code is above

    It is – surprise surprise – of my very own device. Happy to take snippet credit, but even better if some True Coding Wiz could double check that it’s not doing anything grievously unintended.

    #122319

    Link added as Log 201 in here

    Snippet Link Library

    Well done Nonetheless … the credit is all yours … please accept my apologies for doubting your ability! 🙂

    #122329

    I find that ‘doubting my ability’ is a very safe starting point. I’m so rarely disappointed!

    1 user thanked author for this post.
    #191331

    Thanks, @nonetheless  so helpful, as the other position managements are based on position size which would not necessarily work unless the underlying value of the contract remained the same. It would only work at that one time, eg. if index 20,000 vs 10,ooo, the value of that one contract is very different.

    However i have one question, on line 16 why have you multiplied factor by margin? :

    If factor is say 20, and leverage is 1/20, then would that not just make the denominator = the entire value of the underlying product then (without any leverage)? So if say the starting position of 1 contract that is a margin cost is $700 for 1 DAX contract currently, at a 20:1 leverage available, and a factor of 20 (as increases by 5%), and you have 100% profit = $700. Then your calculator is:

    positionsize = 1 + 700/(20)x(14000*.05)

    positionsize = 1.05 

    Instead of the positionsize = 2, which it should be.

    Would this not work better?

    Also i added in ROUND(a, digits), as depending on the contract, IG would only accept position sizes to one decimal place, or a whole number; so need round it to the nearest. Otherwise might not be able place the trade.

     

     

    #191345

    why have you multiplied factor by margin?

    because it wasn’t my intention to put all of the strategyprofit towards the new margin cost; factor of 20 means you are only reinvesting 1/20 of your gain. The factor value can be anything, depending on how aggressively you want to reinvest your profits. If you really want to use all of it then you could have a factor of 1 … but I think you’ll find that will blow up your account. Try optimising f with MM switched on, see what happens.

    I am not using that MM any more, but when I was using it I found that anything less than 10 was trouble (in real world trading). A lot will depend on your particular strategy, the WIN%, Risk/Reward ratio and the general distribution of losses.

    Rounding is definitely a good idea but I round to 2 decimal places and IG seem okay with it.

    I think that IG Oz (and most other places) have leverage of 0.05 for both tier 1 and 2 so you could simplify it by removing margin2, factor2 etc…

    1 user thanked author for this post.
    #191359

    Hi thanks, Makes sense. Yes i backtested and had something looked almost like a bell curve lol, rapidly up BUT then rapidly down. But yeah now i understand what you were doing i will try backtest with different values for the f and see what the equity curve looks like.

    Yes your right, we only have the 20 leverage available in Australia for main indices or 10 for the other indices. So can simplify it.

Viewing 12 posts - 1 through 12 (of 12 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login