Close All Positions
Close All Positions issues a market close on every open trade simultaneously when the connected signal becomes truthy. It is the broadest exit primitive — ideal for kill-switch scenarios, end-of-session flat rules, or emergency risk responses that need to clear the entire portfolio in one step.
How It Works
- 1
Connect any boolean or numeric signal to the node's input port.
- 2
On each tick, the node reads the last non-null value from the signal. If it is non-zero, triggered is set to true.
- 3
When triggered, a close command is dispatched for every position tracked by the position state manager — not just the most recently opened one.
- 4
If no positions are open, the node is a no-op and produces no side effects.
Parameters
No configurable parameters.
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Input | ||
| input | signal | Trigger signal. Non-zero last value closes all open positions. |
| Outputs | ||
| triggered | boolean | true when the close-all command fired on the last tick. |
| lastSignalValue | number | null | The last non-null value read from the input. |
Use Cases
End-of-session flat rule
Wire a time signal that fires at 15:55 each day to guarantee no overnight exposure, closing all open longs and shorts simultaneously.
Volatility kill-switch
Connect a VIX spike detector or ATR threshold breach signal. If market volatility explodes beyond tolerance, the node empties the book immediately.
Portfolio drawdown guard
Compute a rolling drawdown metric and trigger Close All when portfolio equity drops more than X% from peak — automatic catastrophic-loss prevention.