Closing half a position

Forums ProRealTime English forum ProOrder support Closing half a position

Viewing 4 posts - 1 through 4 (of 4 total)
  • #136576

    If I’m in a trade and price moves favourably, I am trying to close half the position and set a stop so that the trade can’t lose. I’ve written this simple code to help me debug it. It does’t seem to work on my spread betting platform. Could someone please tell me whether it should be possible and I’ve done something wrong in the code, or if there’s another way to do it? If it’s not possible on a spread betting platform, is it possible with CFDs?

    My screenshot shows that the code runs; Stopmoved = 1 and Soldhalf = 1, but there is no indication that the buy is executed and COUNTOFSHARES never changes to 1.

    Many thanks in advance.

     

     

    #136583

    Partial closure of positions is not allowed in automated trading, as of this writing. We all hope it will be in the future.

    Still, it is allowed in backtesting.

     

    #136601

    Partial closure is possible in backtesting even if IG don’t allow it in live trading but also your code at line 10 is

    If you want to partially close a short position then you must use EXITSHORT and not BUY. BUY will reverse the position and all short positions will be closed as it is not possible to be long and short at the same time in a ProOrder strategy.

    #136885

    Thanks, robertogozzi and Vonasi, and I take the point that I should have used EXITSHORT.

    Nicolas’ post here made me think that I could close half the position: https://www.prorealcode.com/topic/bollinger-band-coding-help-please/#post-80959

     

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

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