The new distance is SIGNED by position direction (mirrors how ClientStrategy
applies the shift): a stop-loss moved past the entry into the profit zone
produces a negative distance, so any target price is expressible —
slPercentShiftToPrice(slPriceToPercentShift(x, ...), ...) === x holds for
targets on both sides of the entry.
Convert an absolute stop-loss price to a percentShift for
commitTrailingStop.percentShift = newSlDistancePercent - originalSlDistancePercent
The new distance is SIGNED by position direction (mirrors how ClientStrategy applies the shift): a stop-loss moved past the entry into the profit zone produces a negative distance, so any target price is expressible —
slPercentShiftToPrice(slPriceToPercentShift(x, ...), ...) === xholds for targets on both sides of the entry.LONG: newSlDistancePercent = (effectivePriceOpen - newStopLossPrice) / effectivePriceOpen * 100 SHORT: newSlDistancePercent = (newStopLossPrice - effectivePriceOpen) / effectivePriceOpen * 100
Example