Closes out the entire position or the entry if the specified percentage of the maximum profit is lost after the profit has reached the specified tick value; generates the appropriate Stop order depending on whether the position is long or short. For example, if the specified profit is 100 ticks and the specified percentage is 50, and the profit has reached the maximum of 120 ticks, the position will be closed once the profit falls back to 60 ticks.
SetStopPosition and SetStopContract or SetStopShare functions determine whether single SetPercentTrailing_pt order will be applied to the entire position or multiple SetPercentTrailing_pt orders will be applied to each entry in position individually; by default, SetPercentTrailing_pt is applied to the entire position.
SetPercentTrailing_pt function is evaluated intra-bar and not only on close of a bar, and can exit within the same bar as the entry.
- Profit - a numerical expression, specifying the tick value of the profit that must be reached first
- Percentage - a numerical expression, specifying the maximum loss of profit in percent
This function can only be used in signals.
SetPercentTrailing_pt function does not factor in commissions or slippage.
Generate an exit order for the entire position if 50 percent of maximum position profit is lost after the profit has reached 25 ticks:
Generate an exit order for the entry if 25 percent of maximum per entry profit is lost after the profit has reached 5 ticks: