Function tpPercentShiftToPrice

Convert a percentShift for commitTrailingTake back to an absolute take-profit price.

Inverse of tpPriceToPercentShift.

newTpDistancePercent = originalTpDistancePercent + percentShift LONG: newTakeProfitPrice = effectivePriceOpen * (1 + newTpDistancePercent / 100) SHORT: newTakeProfitPrice = effectivePriceOpen * (1 - newTpDistancePercent / 100)

// LONG: entry=100, originalTP=110, percentShift=-3
const price = tpPercentShiftToPrice(-3, 110, 100, "long"); // 107
  • Parameters

    • percentShift: number

      Value returned by tpPriceToPercentShift (or passed to commitTrailingTake)

    • originalTakeProfitPrice: number

      Original take-profit price from the pending signal

    • effectivePriceOpen: number

      Effective entry price (from getPositionEffectivePrice)

    • position: "long" | "short"

      Position direction: "long" or "short"

    Returns number

    Absolute take-profit price corresponding to the given percentShift