Partial closure of positions when price is retracing – A complete function

Now that multi-timeframe support is available for ProOrder, there are many new possibilities for us, including position management in a more refined and faster way than before.

Indeed, it is now possible to trade a strategy that makes trading decisions in a timeframe different from the one we will use to manage its positions.

In this article, I’m going to expose a rather simple function of partial closure of position when the price retraces to your disadvantage.

To close or not to close? That is the question!

Entering position is easy! But how to get out? It is often much more difficult to manage a position exit than to find the best way to enter it.

Should we close on a contrary signal? On a support or a resistance? Or through a thousand other arithmetic tests based on empirical statistics? Hard to say. In fact there would be only one good way, it is based on the behavior of the price, it is the purpose of the function below.

Partially close your position when the price is continuously retracing

The idea of the function is simple:

If the price was in profit of X points, then one starts the function of partial closure. At this point, if the price retrace Y points from the highest price (for a long order), then we close Z percent of the remaining position. The highest price reached is then reset to the current price. And so on until exhaustion of the position (its total closure).

That’s the function code, which incorporates a simple SuperTrend indicator-based strategy on a 15-minutes timeframe:

The parameters are as follows:

  • size = 10

Size of the initial position opened by the strategy.

  • mincontracts = 1

Minimum contract size to close (corresponds to the minimum size possible for the instrument), so to set according to the instrument on which you will perform this function.

  • trigger = 20

From how many points of profit the function will start

  • pointback = 5

Step to close a position, in points, since the highest price (BUY) or lowest (SELLSHORT) ever reached

  • closepercent = 20

Closure size at each level, in this example, 20% of “size” = 10*0.2 = 2 contracts

Buy position – partial closure:

Extend the function with many other ideas!

Many ideas could be added to this way of managing closures, for example:

  • allow closures only if the price is above / below a moving average or any other indicator,
  • no longer allow partial closure if the order is already at breakeven,
  • change the closing size at each step,
  • achieve a dynamic closure stage based on other analyzes,
  • etc.

 

Share this

  1. gone_mexico • 08/08/2018 #

    I’m a little confused on whether ProOrder supports partial closures or not. The article above suggests that this is now supported. However, every other post I’ve seen suggests it’s not supported. And indeed when I click ‘Prepare for automatic trading’, I get told explicitly that partial closures are not supported. Can you please confirm whether the code above is in fact supported by ProOrder (as suggested) or whether in fact this is only supported in back testing mode.

  2. Diego Franchino • 08/08/2018 #

    I’ve just tried the code with ProOrder, but partial closures are still not allowed!

    • Nicolas • 08/08/2018 #

      Still not released officially for live account, but you can ask your broker to activate it for your personal account now.

  3. Diego Franchino • 08/08/2018 #

    I’ve asked IG to activate the multiframe feature yet, I’ll try also for partial closures. Thank you!

  4. gone_mexico • 08/08/2018 #

    I have multi time frame enabled from IG on my account. But this still doesn’t work…

    There’s no restriction to partial closures in back testing mode (doesn’t require a new timeframe). However, I have put my partial closures in another timeframe with a view to uploading to ProOrder. But as soon as I click on the ‘Automatic Trading’ tab to prepare my code for uploading to ProOrder, I get the usual message about ‘Trading systems with orders that partially close cannot be sent to ProOrder’.

    I therefore don’t see how to make this work with ProOrder. (even when IG have enabled the timeframe support).

    Is there something else that I’m missing?

  5. gone_mexico • 08/08/2018 #

    IG confirmed that partial closures is still not supported on ProOrder. (not even available in beta).

  6. Diego Franchino • 08/08/2018 #

    ProRealTime confirmed that partial closures is still not supported on ProOrder, just on manual mode for now.

    • Nicolas • 08/08/2018 #

      Yes, amongst other things, it will be activated in October.

  7. Jeje • 08/08/2018 #

    Hello Nicolas,
    I have phoned to IG yesterday. They confirm that partial closures are not yet allowed by ProOrder. Perhaps in the next version… but when ? IG doesn’t know when.
    A great thank you Nicolas for your code.

    • Nicolas • 08/08/2018 #

      If IG doesn’t know, I can’t help 🙂

  8. Leo • 08/08/2018 #

    Hi all
    I asked IG when this option will be available.
    They reply:
    “might take a long time since there’s only a few people requesting it and we work on a priority list whereas as we implement or initiate a function due to its demand from clients so it may take a while for us to implement this as the demand is too small”
    Then I encourage all of you to request this option and make a bit of pressure.
    Cheers

  9. Precision • 08/08/2018 #

    I sent this to IG just now

    Pro real time does not allow partial exits in auto trading.
    It allows it only in back testing, but this is such a fundamental feature which is an absolute must to trade effectively “like a pro” and yet your platform prohibits it.
    This raises the question why it is so named as PRO real time? when the reality is that it is impossible to trade like a pro with it via IG as we cannot partially close.

    You have many requests for it in the forum and nothing has been done, please see the thread here and give the people what they need!
    https://www.prorealcode.com/blog/learning/partial-closure-positions-price-retracing-complete-function/

    • Nicolas • 08/08/2018 #

      If you want to send a request directly to PRT, you can use their website.
      Partial exit is functional, but sill some server-side development is needed before its official public release. Don’t ask me about ETA, I don’t know.

  10. s00071609 • 08/08/2018 #

    Hi,
    I was trying to forward test a strategy with Partial close but When I run the strategy in back test mode it works fine, but in autotrade mode its giving message – Trading system with orders that partially close the position cannot be sent directly to pro order…………..
    Why is this happening?

    • Nicolas • 08/08/2018 #

      Because it is still not possible in live trading…………..

  11. s00071609 • 08/08/2018 #

    So what is this code for? Is IG able to activate it on request?
    I was actually forward testing in IG demo account

    • Nicolas • 08/08/2018 #

      At the time I published this post it was near possible, but still not actually!

  12. s00071609 • 08/08/2018 #

    Ok, so the option would be to open 2 positions. My question is does it allow 2 separate positions to be opened in same instrument and then either trail one of them or sell it market if a condition is met? Similar thing as your code above but with two units

    • Nicolas • 08/08/2018 #

      No, orders can’t be treated separately, so that’s the purpose of partial closure.

  13. s00071609 • 08/08/2018 #

    ok – how about having 2 long or short strategies on 1 instrument – both should open a trade at the same time. Would this be feasible?

    • Nicolas • 08/08/2018 #

      if the conditions are the same, orders should open at the same time, if your broker accept it of course. Strategies can’t interact between them, so each of your order will be completely independent in this case.

  14. s00071609 • 08/08/2018 #

    thanks

  15. Gianluca • 08/08/2018 #

    guys is partial closed allowed now?

    • Nicolas • 08/08/2018 #

      yes, it is possible now with prorealtime v11. Enjoy!

  16. oliTR • 254 days ago #

    hello, I can read this partial closure function doesn’t work on IG but that’s from 2018.. so would it work now, in 2024, on IG with PRTv12 ?

avatar
Register or

Top