Difference between countOfPosition and actual positions open

Forums ProRealTime English forum ProOrder support Difference between countOfPosition and actual positions open

  • This topic has 14 replies, 3 voices, and was last updated 1 year ago by avatarJohan.
Viewing 15 posts - 1 through 15 (of 15 total)
  • #204890

    I have some weird stuff happening with count of positions. First i calculate how many lots to trade – which can include decimal, like numLotsFull = 4,6 lots. Then when i compare numLotsFull with countOfPosition i sometimes (not on all trades) get a difference of 0.1 lot.

    numLotsFull = 4.6
    countOfPosition = 4.59

    Why is this happening and why is it random? The difference of 0.1 lot is always the same but the difference is only on some of the trades.

    #204893

    I manually went through and defined lot size and saw the following pattern…

    2.3 = 2.29
    4.6 = 4.59
    9.2 = 9.19
    18.4 = 18.39

    The patterns is that if you double 2.3 you get 4.6 and if you double that you get 9.2 and so on. All these numbers get the 0.1 diff. But if you put 2.4 or 2.2 there’s no diff.

    #204895

    4.1 also gets the difference which is even more weird! countOfPositions = 4.09

    What is going on 😀

    #204897

    What is going on 😀

    Internal rounding errors. I will try to find in my code how I solved them …

    #204898

    Thanks that would be very appreciated!!

    #204900

    It is not easy to track down (too many code versions – and today it does not bother me any more). Below you can see the effect (undoubtedly the same you see).
    If you follow from bottom to top, you can see an Entry of 10.19 contracts that Exits per means of CountOfPosition but that comes up with 10.18 contracts. That leaves 0.01. That bit goes out later, when the program decides to Exit again (OnMarket remains true so it will keep on trying to exit that position).

    The descriptive text from myself  I found resides in thee 2nd screenshot. For now this is for reference. It also mentions in which version of the code I solved it. So, on to that … (see upcoming post).

    #204904

    I guess i could do like this:

    #204906

    Notice that MyCountOfPosition is just equal to CountOfPosition (though the ABSolute of it).

    LotSizeBase – the one without issue, is defined like this :

    And PositionAmount is easily defined like this :

    You will see this value back in that descriptive post I showed.

    Thus with some hoopla between that PositionAmount and what CountOfPosition makes of it – BUT with an

    in between it, it can well be that the Abs function implies the culprit (looking at it today).

    You should be using Abs just as well. You could change it to

    … which theoretically could help.

     

    PS: For me it was relatively easy to track down because not long before I started to use CountOfPosition to more easily exit all (after adding position underway), but otherwise … see that descriptive post and it is exactly the same as with you … it depends totally on the values itself whether it would misbehave or not and you’d have no clue …

    #204914

    Interesting!

    I dont think it’s an abs() problem. I’ve tested this:

    And buying 4.1 lots still makes 4.09 open positions. No abs() used. So it’s obvious to me that this is some PRT/IG problem. Some decimal combinations of lot sizes is just being wrongly opened with this 0.01 difference.

    #204922

    And buying 4.1 lots still makes 4.09 open positions.

    All right, careful now. I am never exactly testing *that*, so you very well could be (will be ?) correct on that.
    Fact is : I never had the problem since (see posts), and I never had the problem prior to using CountOfPosition as a means to exit (at ~30 trades per day).

    In the end this could be a matter of not getting exactly what you asked for (ask 4.1 and get 4.09), while CountOfPosition rounds that the wrong way. Or maybe even : rounds it correctly but the negative quantity (for Short) works out differently for positive (Long) – while at the same time no rounding may be in order but cutting (taking the integer).

    If you can isolate the issue with a few lines of sample code, you can make a Technical Report of it by means of the Help menu. Will that help you ? maybe in a year of time, maybe sooner, maybe never. So the moral : work around it (*and* make that report). That will help instantly. Just an advice based on experience. 🙂

     

    #204927

    You are right, I can replicate with 4.1 lots, not below. COUNTOFPOSITION is correct, because order opened size is 4.09. I’m reporting it also.

    #204947

    You are right, I can replicate with 4.1 lots, not below. COUNTOFPOSITION is correct, because order opened size is 4.09.

    If CountOfPosition is correct then how can I

      Sell CountOfPosition Contracts At Market

    and be left with 0.1 contracts of positition ?

     

     

    #204949

    That’s really weird 😆

    The issue had been identified and a fix is in the pipe 😉

    #205010

    The issue had been identified and a fix is in the pipe 😉

    Great Nicolas. Thanks! 🙂

    #205011

    Until the fix is rolled out may be you can help me with a work around… I’m trying to implement partial close on EUR/USD Mini – that take into account minimum of 1 lot size.

    Trade if criteria’s are met. tradeLots is set based on 2% of  capital and the stop risk. Minimum 1 lot.

    Exit is made like this… First i check if numLotsFull is equal to abs(countOfPosition) so i can decide how many lots the exit. If abs(countOfPosition) is 1 i exit full trade at priceTarget1. If abs(countOfPosition) is greater then 1 but under 2 (ex 1.6) then i exit 1 lot (numLotsBigPart) at priceTarget1 and then the remaining 0.6 lots (numLotsSmallPart) at priceTarget2. If abs(countOfPosition) is greater then 2 i exit half of the lots at the two price targets. After first target is met i move stop to break even. Thats why numLotsFull = abs(countOfPosition) is so important.

    So the problem is… If numLotsFull is 4.1 but abs(countOfPosition) is 4.09 my exit code fails.

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

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