DocsActionClose Position

Close Position

ExitAction

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. 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. 2

    When the value is non-zero (truthy), the node sets triggered = true and fires a close command to the active position.

  3. 3

    If no position is currently open, the node is a no-op — it does not error or queue the close signal.

  4. 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

PortTypeDescription
Input
inputsignalTrigger signal. Non-zero last value closes the active position.
Outputs
triggeredbooleantrue when the close command fired on the last tick.
lastSignalValuenumber | nullThe 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

No-position guard. The node checks getCurrentPosition() before firing. If no trade is open the signal is silently ignored — no errors are thrown.
One per strategy. You can use multiple Close Position nodes in the same graph, each wired to a different exit condition. All fire independently.
TP/SL still active. Wiring a Close Position node does not disable the Take Profit or Stop Loss exits on Open Position. Whichever condition triggers first closes the trade.

Related Nodes