Set Exit Condition Node

Set Exit Condition closes a trade leg the moment a condition turns true: a cross back, a lost level, a trade that's had its chance. How it's checked, how it works beside a bracket, and why a state can close a trade too early.

NodeBy AlgoLiftUpdated 3 min read
On this page 6How it worksExample: out when the cross reversesSettingsUse something else whenWhen it doesn't behaveGoing further

Some trades shouldn't end at a price. They should end when the reason you took them stops being true: the fast average crosses back, price loses the level it broke, the move you expected never comes. Set Exit Condition closes the leg the moment its condition turns true.

Takes
One true-or-false condition
Gives
Closes the leg the moment the condition is true
Reach for it
Getting out on a signal rather than at a price

How it works

Drag Exit Condition off the setter rail of a Trade node, and wire a condition in. From the tick after the fill, it's checked on every tick, and the first time it reads true the leg closes at market, with the run's usual latency and fill model. A condition with no value reads false, so an indicator still warming up never closes anything.

It works with or without a bracket. Beside a Bracket Order, the bracket's stop and target stay in force and whichever comes first closes the trade: "exit on the signal, with a hard stop behind it" is one bracket plus one exit condition. Without a bracket, an exit condition alone is enough for the builder to accept the leg, though a leg with no stop is a leg with no plan if the signal never comes.

A leg can have several Set Exit Conditions, and every one runs: the leg closes on the first of them to fire, as if they were ORed. A condition that has no value yet (an indicator still warming up) never closes a leg on its own. One Exit Condition fed by an OR through a Logic node is the same rule, and it puts every way out of the leg in one place you can read, so it's the tidier build when the reasons are related.

The common trap is wiring in a state when you meant an event. "Exit when RSI is above 70" is fine on a long bought with RSI at 30. "Exit when price is under the 50 EMA" closes a trade at once if price was already under it when the trade opened. Exits usually want an event, the moment something changes, which is what a Crossover gives you.

Example: out when the cross reverses

Say you trade ES 5m and go long when the 9 EMA crosses above the 21. You'd like to stay in while the trend holds and leave when it turns, with a stop in case it turns violently.

Attach a Bracket Order to the leg with a 10-point stop and a far 40-point target. Then drag an Exit Condition off the same Trade node and wire a Crossover into it: the 9 EMA on a, the 21 EMA on b, direction Below. The trade now ends at the first of three things: the cross back, the 10-point stop, or the 40-point target.

Settings

It has no settings. Which leg it closes is decided when you drag it off a Trade node.

Use something else when

Close at a time, or after N minutes
The bracket's Time exit handles clock times, minutes or bars in the trade, and minutes before the close, without building anything.
Get out at a price that moves
A stop or target your logic moves is a price, not a condition, so it belongs in Set Stop Loss, Set Target Profit or the bracket's own inputs.
Cut a trade that hasn't worked in time
Time Since set to this trade's entry, ANDed with "still below the entry price", closes the slow losers and leaves the winners alone.

When it doesn't behave

My trades close a tick after they open

The condition was already true when the trade opened. Turn the state into an event with a Crossover, or AND it with a Time Since set to this trade's entry so it can't fire in the first few bars.

It exits a bar after price broke the line

That's the Bar close clock: a Crossover on bar closes knows about a cross when the bar closes, and the exit follows. To get out the moment price trades through a line, put Current Price on a, the line on b, and set the Crossover's clock to Intrabar.

Going further

If the cross back is meant to be the only way to take profit, give the bracket No target rather than a distant one. The stop stays as the backstop, and the exit condition, the time exit or the stop decides every trade.

When you compare exit ideas, keep the entries identical, so the only difference in the results is the exit. And decide which exit fits the idea before you look: each variant you try is one more look at the same history.

Or ask the copilot