Skip to content

Latch

Flow · State

Latch node on the canvas

SR-flip-flop: once set fires true, output stays true until reset fires. If both fire on the same bar, reset wins (safe default — 'reset has priority' avoids stuck-on bugs). Useful for 'arm a trade after structural break, hold the green light until the break is invalidated'.

Latch is a memory cell. Once a Set signal fires, its output stays true — and keeps staying true, bar after bar — until a Reset signal fires. It's the electronics SR flip-flop brought to trading, and it solves a problem pure per-bar logic can't: holding a state between events. "Once structure breaks bullish, stay armed for longs until that break is invalidated" is a Latch, not a comparison.

How it works

The block has a Set input that flips the latch on and an optional Reset input that flips it off. The Q output holds the current latched state: true from the bar Set fired until the bar Reset fires, then false until Set fires again. If both fire on the same bar, Reset wins — a deliberate safe default, because "reset has priority" prevents stuck-on bugs where a latch can never clear. Without a Reset wired, the latch stays on forever after the first Set.

When to use it

Use Latch whenever a condition should arm a state that persists until something cancels it. The canonical smart-money case: a bullish Market Structure break arms a long bias (Set), and you hold that green light — taking pullback entries within it — until a bearish break invalidates it (Reset). It's also how you implement "stay in setup mode after a Liquidity Sweep until price leaves the zone." Anywhere you need "remember that X happened until Y happens," Latch is the block.

Example

Arm longs after a structure break: wire a bullish Market Structure BOS into Set and a bearish CHoCH into Reset; the Q output is true for the whole bullish phase. And Q with your pullback trigger into a Buy Signal, so you only take longs while the bullish structure holds. Backtest in the Tester.

Tips & gotchas

  • It remembers between events — the thing per-bar comparisons can't do.
  • Reset wins ties — a safe default that avoids stuck-on latches.
  • No Reset = on forever after the first Set; wire a Reset unless that's truly intended.
  • Pair Q with a trigger via And — the latch sets the context, the trigger sets the timing.

Inputs

Socket Type What to wire in
Set signal Pulses the latch on.
Reset (optional) signal Pulses the latch off. Optional — without it, the latch stays on forever after first set.

Outputs

Output Type Plots as Description
Q signal Signal arrows Latched state.

Reference auto-generated from the block catalog · category Flow.