Trailing-stop orders are closing orders that follow the price as it moves in a positive direction.
If the price reaches Activation Price (“Profit”), reverses in a negative direction by a specified percentage of deviation, the trailing-stop will close the deal by the market order.
For Long positions, trailing-stop orders help to maximize the selling price of the asset, while for Short positions they help to minimize the buying price. In other words, trailing-stop is relevant for both long and short bots.
It is recommended to use a Trailing stop for the Activation price (the “Profit” field) of at least 1% and a “Deviation percentage” of at least 0.5%.
In the example above, it will work like this:
1. When the PnL of position reaches 1.2%, the bot calculates the closing level (1.2-0.5=0.7) and sets a closing order at 0.7%
2. If the price then goes down and the bot finds out that the PnL of position has become 0.7% or less, bot sends a market order to close.
3. If the price goes up, the bot recalculates a new closing level from the new increased price during each check (1.3-0.5=0.8, 1.4-0.5=0.9 and so on)
Currently, trailing is supported for Binance, OKX and BingX exchanges.
Let’s look at the Long example
At 12:01, when the asset price is 40,000, the bot placed a trailing-stop order for take profit at the activation price of 42,000 (stopPrice on the chart), with a deviation percentage of 7.5%.
Between 12:01 and 12:02, a series of trades pushed the asset price up to 41,500.
Between 12:02 and 12:03, a series of trades caused the asset price to decrease to 39,000.
A series of trades between 12:03 and 12:04 results in an increase in price. When the asset price reaches or crosses the activation price of the trailing stop order (stopPrice), the order starts to follow the price change. The first trade that satisfies this condition sets the “highest price”. In this case, the highest price is 42,000. And if the price deviates downward by 7.5% from it, the order will be executed.
Next, a series of trades causes the price to increase to 45,000, which updates the “highest price”. Now, for the trailing stop order to execute, the price needs to deviate down 7.5% from 45,000.
Between 12:04 and 12:05 brings the price down to 44,000. That’s about 2.2% – not enough to execute the order.
Between 12:05 and 12:06, trading raises the price to 46,500. This is again above the previous high, which updates the highest price. And now the execution price of the trailing stop order is: 46 500 * (100 – 7.5) / 100 = 43 012,5.
Trading between 12:06:00 and 12:06:50 causes the price to fall to the price of 43,012.5. The trailing stop order reacts to this event by executing the order.
Thus, the initial take profit at the price of 42,000 closed at the price of 43,012.5.