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

Register or