Skip to content

Value When

Flow · Capture

Value When node on the canvas

Capture the value of X on the most recent bar the condition was true, and hold it until the next occurrence. NaN before the first. E.g. 'the RSI at the last swing high', 'price at last signal'.

Value When captures the value of a series at the moment a condition was last true, and holds it until the condition fires again. It's a sample-and-hold: "what was the RSI at the last swing high?", "what price did the last signal fire at?" — a snapshot you can keep referencing bars later.

How it works

Two inputs: a condition signal and a value X. Each bar the condition is true, the block latches the current X and outputs it; on bars where the condition is false, it keeps outputting the last latched value. Before the condition has ever been true there's nothing to hold, so it emits NaN. Lookahead-free.

When to use it

Use it to freeze a reference from a past event and compare against it live: the price at the last breakout (for a retest), the ATR at entry (for a fixed stop distance), the level of an indicator at the last swing. It's how you turn "the value back then" into a usable line that persists between events.

Example

Retest of the breakout: wire your breakout trigger into condition and close into X, so Value When holds the breakout price. Then compare live price to that held level with CrossesBelow to catch the pullback-and-retest entry.

Tips & gotchas

  • Sample-and-hold — the output is a flat step that only changes when the condition fires.
  • NaN before the first occurrence.
  • X is captured on the same bar the condition is true — align your inputs accordingly.

Inputs

Socket Type What to wire in
When signal Capture X on bars where this is true.
X series / bars Value to capture. BARS uses close.

Outputs

Output Type Plots as Description
value series Line · sub-pane X held from the last true bar.

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