Convert an absolute take-profit price to a percentShift for commitTrailingTake.
commitTrailingTake
percentShift = newTpDistancePercent - originalTpDistancePercent where distance = Math.abs((tpPrice - effectivePriceOpen) / effectivePriceOpen * 100)
// LONG: entry=100, originalTP=110, desired newTP=107const shift = tpPriceToPercentShift(107, 110, 100); // -3await commitTrailingTake("BTCUSDT", shift, currentPrice); Copy
// LONG: entry=100, originalTP=110, desired newTP=107const shift = tpPriceToPercentShift(107, 110, 100); // -3await commitTrailingTake("BTCUSDT", shift, currentPrice);
Desired absolute take-profit price
Original take-profit price from the pending signal
Effective entry price (from getPositionEffectivePrice)
getPositionEffectivePrice
percentShift to pass to commitTrailingTake
Convert an absolute take-profit price to a percentShift for
commitTrailingTake.percentShift = newTpDistancePercent - originalTpDistancePercent where distance = Math.abs((tpPrice - effectivePriceOpen) / effectivePriceOpen * 100)
Example