Trading pair symbol
Percentage adjustment to ORIGINAL TP distance (-100 to 100)
Current market price to check for intrusion
Promise
import { trailingTake } from "backtest-kit";
// LONG: entry=100, originalTP=110, distance=10%, currentPrice=102
// First call: bring TP closer by 3%
const success1 = await trailingTake("BTCUSDT", -3, 102);
// success1 = true, newDistance = 10% - 3% = 7%, newTP = 107
// Second call: try to move TP further (less conservative)
const success2 = await trailingTake("BTCUSDT", 2, 102);
// success2 = false (SKIPPED: newTP=112 > 107, less conservative, larger % absorbs smaller)
// Third call: even more conservative
const success3 = await trailingTake("BTCUSDT", -5, 102);
// success3 = true (ACCEPTED: newDistance = 10% - 5% = 5%, newTP = 105 < 107, more conservative)
Adjusts the trailing take-profit distance for an active pending signal.
CRITICAL: Always calculates from ORIGINAL TP, not from current trailing TP. This prevents error accumulation on repeated calls. Larger percentShift ABSORBS smaller one (updates only towards more conservative TP).
Updates the take-profit distance by a percentage adjustment relative to the ORIGINAL TP distance. Negative percentShift brings TP closer to entry (more conservative). Positive percentShift moves TP further from entry (more aggressive).
Absorption behavior:
Automatically detects backtest/live mode from execution context.