04 Strategies for Closing Positions in Algorithmic Trading

Published at 1723089372.667861

Position-closing strategies, or exit strategies, are an essential component in the development of trading algorithms. These are pre-defined plans by investors to exit a trading position with the aim of protecting achieved profits or limiting losses. The position-closing strategy is crucial because it determines the timing and method of closing a position, directly impacting the effectiveness of the algorithm. Below are 04 commonly used position-closing strategies in algorithmic trading.

1. Fixed Threshold Position-Closing Strategy

To limit losses, investors predefine a stop-loss threshold, which is set below the purchase price (for long positions) or above the selling price (for short positions). When the price reaches the stop-loss threshold, the order is triggered to close the position.

To protect profits, investors set a take-profit threshold, which is above the purchase price (for buy orders) or below the selling price (for sell orders). When price hits the take-profit threshold, the order is triggered to close the position and realize the achieved profit.

In the fixed threshold position-closing strategy, the take-profit or stop-loss thresholds do not change with market price fluctuations. Investors can flexibly combine both fixed take-profit and stop-loss thresholds within the same trading algorithm, or use only one of the two, depending on their objectives and risk appetite.

Example 01: An investor buys FPT stock at 150.000 VND, sets a stop-loss at 10% (135.000 VND) and a take-profit threshold at 20% (180.000 VND). If the price falls to 135.000 VND, a sell order will be triggered to stop the loss. If the price rises to 180.000 VND, a sell order will be triggered to take the profit.

The fixed threshold position-closing strategy is a simple and easy-to-implement method, however, it has some limitations. Since it does not account for market volatility, fixed thresholds (both stop-loss and take-profit) can be easily triggered during strong, albeit temporary, market fluctuations. For stop-loss orders, this means investors might be forced to sell at a low price, missing the chance to hold the position if the price recovers strongly. Similarly, with take-profit orders, closing the position too early may prevent investors from benefiting from further market gains, thus missing out on potentially larger profits. Therefore, investors need to balance between capital protection and profit maximization to determine suitable position-closing thresholds.

2. Trailing Stop Position-Closing Strategy

In the trailing stop position-closing strategy, the initial closing threshold is set similarly to the fixed threshold strategy, based on a percentage or a fixed price distance from the entry price. However, the key difference is that this threshold automatically adjusts according to market price fluctuations, maintaining a certain distance from the highest price reached (for long positions) or lowest price reached (for short positions).

Specifically, for long positions, as the price rises, the closing threshold is adjusted upward accordingly. When the price falls, the closing threshold remains unchanged. If the price drops below the closing threshold, a sell order is triggered to close the position.

Conversely, for short positions, as the price falls, the closing threshold is adjusted downward accordingly. When the price rises, the closing threshold remains unchanged. If the price rises above the closing threshold, a buy order is triggered to close the position.

Example 02: A trader opens a long position in FPT stock at 150.000 VND and uses a trailing stop strategy with an initial closing threshold of 135.000 VND (a fixed price distance of 15.000 VND). As the price of FPT stock changes, the closing threshold is adjusted as follows:

    • Price rises to 160.000 VND (+10.000 VND), the stop-loss threshold is adjusted upward to 145.000 VND (+10.000 VND);

    • Price continues to rise to 165.000 VND (+5.000 VND), the stop-loss threshold is further adjusted upward to 150.000 (+5.000 VND);

    • Price then drops from 165.000 VND to 160.000 VND (-5.000 VND), the stop-loss threshold remains unchanged at 150.000 VND (-0.000 VND);

    • Price continues to decrease to 150.000 VND, the sell order is triggered to close the position).

By using the trailing stop position-closing strategy, investors can simultaneously achieve two goals: limit losses and protect profits. As the price moves favorably, the closing threshold automatically adjusts, helping to “lock in" the achieved profit and minimize the risk of missing out on profit realization. In the event of a price reversal, the closing position (stop-loss) order is triggered, allowing investors to exit the position in a timely manner and minimize losses to an acceptable level.

3. Signal-Based Position Closing Strategy

The signal-based position-closing strategy is a systematic trading approach that utilizes a flexible combination of technical indicators such as RSI, MACD and fundamental analysis factors like financial statement metrics to determine closing criteria (signals). When these indicators meet the predetermined conditions, the position-closing order is triggered.

Example 03: An investor uses the signal-based closing strategy as follows: “When the stock price drops below the 200-day moving average and the RSI falls below 30, sell to close the position.”

When using a signal-based closing strategy, investors need to be aware that not all signals guarantee profitability. The effectiveness of each signal depends on various factors and requires the investor to have in-depth market knowledge.

4. Time-Based Position Closing Strategy

The time-based position-closing strategy involves setting a maximum holding period for a position in advance. When this time period expires, the position is closed, regardless of the market price at that time.

Example 04: An investor buys a VN30F1M futures contract with the goal of intraday trading and wants to avoid holding positions overnight to mitigate off-hours risks. The investor may set the closing time to 14:00 PM on the same day, regardless of whether the trade is profitable or not.

Determining the optimal closing time can be challenging and requires experience and market understanding, as well as the investor’s ability to analyze and manage risk.

 

In addition to the 04 popular position-closing strategies mentioned above, there are many variations depending on the algorithmic trader's needs. These variations can include combinations of the 04 strategies. For instance, in a smart beta strategy, position closing combines time and signal factors. The investor periodically reviews the portfolio at specific intervals. However, instead of closing all positions, they only sell stocks that no longer meet the predefined criteria.

In summary, in algorithmic trading, determining the position-opening strategy is just the beginning. The success of an algorithm depends not only on the ability to predict market trends accurately but also on risk management and profit optimization after opening positions. Here, the position-closing strategy plays a crucial role, helping traders actively manage risk and maximize profits. The principle of “cut losses quickly, let profits run” is often applied to minimize losses and maximize gains when possible, thus providing overall effectiveness and sustainability for the algorithm.