which positions are exited first?

Forums ProRealTime English forum ProOrder support which positions are exited first?

Viewing 4 posts - 16 through 19 (of 19 total)
  • #176765

    You can’t choose which one position is to be closed, just the number of lots to be closed.

    IG don’t know about average prices, they only assign an ID to each opened position. It’s ProOrder which needs an algorithm to keep track of them. It doesn’t sell at an average price, but at the current or selected price, then it updates the average price only to set PositionPerf, SL and TP.

    Then it is more or less as I expected, but wasnt sure if it was first in first out, or last in first out or something different. Thanks Roberto!

    anyway, the only workaround I have come up with to actually control exactly which position is closed is to chop the algo into X number of separate algos. Like this: say I want to take up to max 5 positions. I create the algo, but then copies it into 5 separate, each one containing all the code and the same signals etc. this way they will all “know” which positions we have at any moment, based on the entry and exit conditions etc, but they are each limited to only controlling one of the up to five positions… I have not completed such an algo yet, but this should work, although it takes some extra coding.

    but since first in first out is what I probably want for the strategy I am currently working on it might not even be necessary, we will see.

    #176769

    You can’t choose which one position is to be closed, just the number of lots to be closed.

    IG don’t know about average prices, they only assign an ID to each opened position. It’s ProOrder which needs an algorithm to keep track of them. It doesn’t sell at an average price, but at the current or selected price, then it updates the average price only to set PositionPerf, SL and TP.

    Thanks Roberto, that helps a lot!

    anyway, the only workaround that i have come up with is to create X separate algos, each containing the same entire code. say that i want to take up to max 5 positions, but want to control exactly which positions are exited when, then i copy the algo into 5 separate and run them simultaneously, but I instruct them to only control 1 of these max 5 positions, and since they containg the same signals and conditions etc, they can all “know” at any moment which positions we have, if properly programmed. that should work in theory, but havent tried it yet. wanted to get an answer first to my questions. thanks again.

    #176774

    I made some more checks and I assume ProOrder calculates partial exits on the average price (PositionPrice) to make easier calculations, then on the last position exited it recalculates the whole gains and subtracts what had already been calculated before. So the last exit should not match any previous calculation method.

     

     

     

    #176777

    Long story. Skip if you don’t feel like reading long stories or if you are sufficiently experienced anyway.


    I am not sure what to think of this all. In my view it is as easy as this :

    Scenario 1 :
    Buy 1@50. What did it cost you ? 50.
    Exit 1@52, because the price changed to 52, and you obtain 52 (never mind fees and spread). Apparently you gained +2.

    Scenario 2 :
    Buy 1 @50. What did it cost you ? 50.
    Later, Buy 1@60. What did it cost you ? 60. What did it cost you in total ? 110.
    Exit 1@62 because the price changed to 62, and you obtain 62. What did it cost you in total ? 110-62 = 48.
    Later, Exit 1@65 because the price changed to 65, and you obtain 65. What did it cost you in total ? 110-62-65= –17. Or better said : a gain of +17.

    The latter sentence is better written like this, as that will be the real practice :
    Later, Exit 1@65 because the price changed to 65. What did it cost you in total ? 48-65= –17. Or better said : a gain of +17.

    Scenario 3 :
    Buy 1 @50. What did it cost you ?  50.
    Later, Buy 1@60. What did it cost you ? 60. What did it cost you in total ? 110.
    Exit 1@62 because the price changed to 62, and you obtain 62. What did it cost you in total ? 110-62 = 48.
    Later, Exit 1@59 because the price changed to 59 and you obtain 59. What did it cost you in total ? 48 – 59 = -11. Or better said : a gain of +11.

    Scenario 4 :
    Sell Short 1@70. What did it cost you ? -70.**
    Later, Buy 1@68.*** What did it cost you in total ? -70+68 = -2. Or better said : a gain of +2.
    **): I denote this as -70 because else the math won’t work, plus it is technically a loan, so OK.
    ***): I deliberately don’t call this an Exit Short, because in practice you won’t do it like this either. You just Buy 1 which eliminates the position of -1. In the program you can do the same.

    Scenario 5 (more to your imagination) :
    Sell Short 1@70. What did it cost you ? -70.
    Later, Buy 2@68. What did it cost you in total ? -70+68+68 = 66.
    … And that’s it. You now have an open position of Long 1 at a price which varies and varies, until you Exit the position. Only at that moment you will know the gain. During the open position you will have a cost of 66. However, against that (the other side of the balance) is the daily settled value of the position. Is that 100 on a certain day ? then you can think your gain is 100-66 = 34 at that moment. Is it next day 95 ? then 95-66 = 29.

    In the end you MUST think like the last example always, because that is how it technically works with book keeping; you don’t need to sell the last remaining position of 1 piece in order to “have” the profit or loss of it.

    Lastly, I really don’t see how we would need averages or first or middle etc. orders/positions, because it is about the gain at any moment in time you observe it. You don’t need to maintain the gain, as PRT is doing that for you (and no need to check whether it is correct either);

    When you manually trade through PRT (envision my scenario’s as that), you really really are not going to think about your positions and how they average. PRT will show you the profit for the position you have, no matter how that emerged (with which scenario’s) and if things are going well, you will buy a few more. If you want less risk, you sell a few (or all). There is, however, one thing that may help you in seeing through how things work in reality and how the program should anticipate that … see the attachment;

    Suppose the first line with 32 pieces is doubled to 64, immediately the Latent Profit of 22.98% will he halved to 11.49%. It is easy to see how this works (your position amount doubles, but the gain did not change – e.g. the the exposure is 300 and the gain is 50 (16.67%) which changes to an exposure of 600 but the gain is still 60, this is 8.33%.

    The other way around (halve the position) is mind boggling but I was told that the Latent Profit remains to be 22.98% (I never actually checked it and I am unable to reason it out today). But then (again) I do not care, because if I sell half, hence 16, I know I am going to obtain half of the 300 = 150. Only at the very end (when I sold all of it) I will know my profit. Still, on a daily basis PRT will tell me the profit and I am pretty sure that at selling half, the profit will half too. Thus, my profit of 50 will change into 25 and 25 would still be 16.67% of the remaining exposure of 150. Thus, this is how it is technically done by PRT, which means that you should do that the same way when working in the program and when necessary. The only reason to do that the same, is for being able to communicate with the charts and see the same as your program did/does.

    The below should give you some hints about how the Gain is maintained in the program.

     

Viewing 4 posts - 16 through 19 (of 19 total)

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