The conditions under which an open position is closed. Exit logic can include profit targets, stop-losses, time-based exits, or opposite signals. In code, exit logic checks whether any closing condition is satisfied and then sends a close order. For example, a strategy might exit when profit exceeds a threshold or when an RSI falls below a level. As stated in Forex Strategy Builder documentation: “exit the market signals… are sent by the exit logic of the strategy”.
-
Definition: Rules specifying when to close an existing trade (taking profit, stopping loss, reversing signal, or time expiry).
-
Context: Exit logic produces exit orders (market/limit) when conditions occur. In many trading platforms, this is implemented by calling a close function (e.g.
OrderClose()
in MQL, or implicitly when usingSetStopLoss()
/SetProfitTarget()
in NinjaScript). -
Example (MQL4/5):
-
Example (cTrader cAlgo):
-
Example (NinjaScript):
(Or manually:
ExitLong();
to close a long position.)