I want to create a Bot that adds a trailing stop loss to a position.
I want to create a Bot that adds a trailing stop loss to a position.
13 Apr 2025, 12:14
I would like to create a bot that will execute a trailing stop loss on a position after a market order is executed. Can someone please provide me the code?
・Trailing Start: The number of profit points of the position before trailing end is triggered.
・Trailing Step: The number of points the price must move in the profit direction to move the stop loss next.
・Trailing Distance: The distance from the current price that the stop loss should be placed.
As a filter function, I would like to be able to narrow down by comments, and also add a filter to positions for selling only or buying only.
Specifically, do not add a trailing stop loss to only one position with a buy, but add it to other buy positions.
Also, do not add a trailing stop loss to selling positions, but add a trailing stop loss only to buy positions.
If possible, I would like to add a filter by order number as well.
As an example of setting a trailing stop loss, if the trigger pips is 3 pips and the trailing stop loss distance is 1 pip, when buying, when the bid rate reaches 3 pips, an SL will be created at a position of 2 pips, 1 pip away from the current rate. If the trailing step interval is 0.1 pips, as the price rises, it will move from 2 to 2.1, 2.2, etc.
The above content has been resolved.