The rules that tell the algorithm when to close a position (take profit or cut loss). Exit logic might be a profit target (e.g. close when +X pips), a fixed stop-loss threshold, or a dynamic rule (e.g. trailing stop or reverse indicator signal). Well-defined exit criteria prevent emotional decisions and lock in gains or limit losses consistently. In backtesting and optimization, clear exit logic is just as crucial as entry logic for determining a strategy’s success.