The new distance is SIGNED by position direction (mirrors how ClientStrategy
applies the shift): a take-profit moved past the entry produces a negative
distance, so any target price is expressible —
tpPercentShiftToPrice(tpPriceToPercentShift(x, ...), ...) === x holds for
targets on both sides of the entry.
Convert an absolute take-profit price to a percentShift for
commitTrailingTake.percentShift = newTpDistancePercent - originalTpDistancePercent
The new distance is SIGNED by position direction (mirrors how ClientStrategy applies the shift): a take-profit moved past the entry produces a negative distance, so any target price is expressible —
tpPercentShiftToPrice(tpPriceToPercentShift(x, ...), ...) === xholds for targets on both sides of the entry.LONG: newTpDistancePercent = (newTakeProfitPrice - effectivePriceOpen) / effectivePriceOpen * 100 SHORT: newTpDistancePercent = (effectivePriceOpen - newTakeProfitPrice) / effectivePriceOpen * 100
Example