Position being closed out incorrectly

Forums ProRealTime English forum ProOrder support Position being closed out incorrectly

Viewing 15 posts - 1 through 15 (of 18 total)
  • #122049

    Hi all,

    I have a strategy running, but there is an issue.

    It accumulates more than one position simultaneously. For each position there is an initial stop loss order defined at the time of opening. On occasion when this hard stop loss order is hit, and there one or more positions still open, it is waiting until the end of the bar in which the hard stop loss was hit, and then transmitting an order to close the remaining position(s). I cannot see any way in the code it should be doing this, when the bar close is no where near my dynamic stop loss or profit targets.

    When looking at the ‘Executed order list’ I see the following (please see attachment).  At 8:48 there were 2 simultaneous short positions open. At 9:07 one position was correctly closed out as the hard stop loss was hit. BUT why is the position change value “-1 => 0”, surely it should be “-2 =>-1”? Then three minutes later at the close if the bar, the remaining position is incorrectly closed out.

    Many thanks if anyone can shed light on this, as it is doing my head in!

    #122051

    I cannot see any way in the code it should be doing this

    Neither can we as you haven’t posted the code!

    #122054

    Thanks for the reply.

    This is part of the code which handles the trailing stop:-

     

    Not sure how much it will help without posting the whole system. The code doesn’t hep to explain why the position change value “-1 => 0” on the second row in the short series of trades in the attachment?

    #122055

    Please always use the ‘Insert PRT Code’ button when posting code in the forums. I’ve tidied up your post for you. 🙂

    #122056

    @schizz do you know that positioncount of a short is -1 and for size = 2 shorts it would be -2 etc.

    position count for Longs is 1, 2, 3 etc

    #122059

    Thanks for your response. I do. The variable poscount is derived from the “countofshortshares” which is positive for shorts awell as longs.

    1 user thanked author for this post.
    #122075

    If you are happy that your code is closing positions correctly then we just have to assume that the position change is updated at the close of a bar and having one close mid bar and one close at the close of the bar confuses things.

    It is not possible to live trade with partial position closure so I guess this side of reports has not been given a huge amount of priority and there are a few bugs.

    #122081

    That is a huge bug, if it cant even correctly identify the number of positions remaining open after one has hit a stop loss order mid-bar.

    Is there a way of officially reporting issues and getting them addressed?

    #122100

    Yes send a report via your platform… but bare in mind that due to coronavirus a lot of PRT staff are working from home, especially those in Paris and so customer service and priorities are a little different at the moment.

    To me that is not really a huge bug. You can track the amount of positions opened and closed within your strategy with your own code and it does not effect the performance of the strategy.

    #122123

    It certainly will affect the performance of the strategy, if the platform decides to close further open positions just because one of them has hit its hard stop loss.

    It doesn’t do it in back testing, I haven’t noticed the same thing when forward testing in demo either. I’ll have to try and work out the conditions for when the platform does it, and code around it. Disappointing to have to do, because of a platform deficiency. One thing I wont be doing is dispensing with stop loss orders issued to the broker at time of position opening. PRT is proving itself unreliable, it would be a huge risk to rely on it to close positions out correctly in all market conditions.

    #122124

    Not being able to undertake partial exits (in Real Live Trading) is a known / accepted  ‘limitation’ of the PRT Platform.

    If you were able to find out why … it may even be a requirement laid down by IG??

    #122144

    Sorry schizz but your posts are getting confusing. Your first post seemed to be questioning how your closed orders are reported by the platform but now you seem to be complaining that your strategy does not close positions correctly. As said before partial position closure is not allowed by IG so if you try to run a strategy live that has EXITSHORT 1 CONTRACT AT MARKET or SELL 1 CONTRACT AT MARKET then it will be rejected and you won’t be able to run it live anyway

    If your strategy has SET STOP or SET PROFIT orders in it then each opened position will have different order levels to close it.

    If your strategy has  SELL AT MARKET or EXITSHORT AT MARKET instructions then all positions will be closed as they would be if you had a BUY or SELLSHORT order that occurred whilst already having open positions in the opposite direction.

    What exactly your issue is is difficult to discern and we don’t have your code to see how it works compared to how you think it should work so really we are just guessing what your issue is and so we can only guess an answer!

    #122190

    Just to  be clear, my strategy does not attempt to partially close positions.

    It will open multiple positions (either all LONGS or all SHORTS), each with their own individual SET STOP order. SELL AT MARKET or EXIT SHORT AT MARKET commands are used to close out ALL positions simultaneously.

    The issue I saw on two occasions last week, in the first week of live trading the system, was for the market to re-trace and the most recently opened position hit its SET STOP order mid-bar and (correctly) close. However at the close of the same bar, the remaining open short positions were also closed, despite the market being at least 20 points from the nearest EXIT SHORT level.

    I added the attachment because that is an example of this scenario happening in a series of four trades and may be related to the issue.. In particular  I am confused why the “Pos Chg” value for the SET STOP trade at 09:07 says “-1>0”. As can be seen from the trade immediately below it, there were TWO short positions open at the time. Why is it not “-2 > -1”?

     

     

    #122192

    However at the close of the same bar, the remaining open short positions were also closed,

    As partial closures are not allowed I guess above could be due to the rule that is built in under your scenario … so intrabar 1 x stop is hit so Exit  1 x  position  and end of bar Exit all remaining positions … result all positions closed in same bar??

    #122194

    Possible I suppose, but:-

    1:) Doesn’t happen every time a SET STOP order is hit

    2:) For my purposes that would make PRT pretty much unusable as a trading platform. I appreciate I have not been using PRT that long but I can’t be alone in thinking that any automated trading platform worth its salt should not be having this kind of bug.

    Bit mystified really as it seems such a huge issue I cant believe its not been raised before. Does no-one trade strategies with multiple open positions and SET STOP orders?

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

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