pine-script-trailing-stop-backward-movement-without-ratchet
Trailing stops implemented without math.max(nz(prevStop), newStop) can move backward on price retracements, defeating the lock-in purpose. Always declare var float dynamicSL and update with math.max(nz(dynamicSL), calculatedStop) to enforce one-directional ratcheting across bars.