Close Position
Close Position monitors the current open trade and closes it at market price when the connected signal becomes truthy. It is complementary to the TP/SL exits managed by the Broker node — use it for indicator-driven or time-based exits that are not captured by fixed price levels.
How It Works
- 1
Connect any boolean or numeric signal to the node's single input port. The node reads the last non-null value each tick.
- 2
When the value is non-zero (truthy), the node sets triggered = true and fires a close command to the active position.
- 3
If no position is currently open, the node is a no-op — it does not error or queue the close signal.
- 4
The close executes at the next available market price, respecting slippage configured on the original Open Position node.
Parameters
No configurable parameters. Behaviour is entirely driven by the input signal.
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Input | ||
| input | signal | Trigger signal. Non-zero last value closes the active position. |
| Outputs | ||
| triggered | boolean | true when the close command fired on the last tick. |
| lastSignalValue | number | null | The last non-null value read from the input (for debugging). |
Use Cases
Indicator-based exit
Connect an RSI overbought signal (RSI > 70 logic node) to close a long position when momentum exhausts, independently of the TP price level.
End-of-day flat rule
Wire a time-based signal that fires at market close each session to ensure no overnight exposure.
Opposite signal exit
Use the same MA crossover signal that would trigger a short entry to also close an existing long, flipping the position cleanly.
Tips
getCurrentPosition() before firing. If no trade is open the signal is silently ignored — no errors are thrown.