Wait

Confirmation gateLogic

The Wait node is a confirmation gate: it opens on a trigger signal (Input A) and fires 1 only if a confirmation signal (Input B) arrives within a configurable candle window (maxCandles). If the confirmation does not arrive in time, the gate closes silently and no output is produced. This makes Wait ideal for requiring a second event to validate an initial setup before taking action.

How It Works

  1. 1When Input A = 1, the node opens a waiting window starting at the current bar.
  2. 2On each subsequent bar, the node checks whether Input B = 1 and the elapsed time is within maxCandles.
  3. 3If B = 1 arrives within the window: output is set to 1 at that bar, and the gate closes (resets).
  4. 4If maxCandles bars pass without a B = 1: the gate closes with output remaining 0. No signal is fired.
  5. 5A new A = 1 re-opens the gate, resetting the countdown timer.
Note: The window is measured in bars (candles), not clock time. On a 1-hour chart, maxCandles = 10 means "within the next 10 hours". On a 1-minute chart, it means "within 10 minutes".

Algorithm

  • Both inputs are aligned by timestamp. Only bars present in both series are processed.
  • Output initialised to all zeros.
  • Scan forward: when A[i] === 1, record waitingFrom = i.
  • While waitingFrom !== null: at each bar compute elapsed = i - waitingFrom.
  • If elapsed > maxCandles: set waitingFrom = null (timeout, gate closes).
  • If B[i] === 1: set output[i] = 1, set waitingFrom = null (confirmed, gate closes).

Parameters

NameTypeDefaultDescription
maxCandlesinteger10Maximum number of bars to wait for the confirmation signal after the trigger fires. Must be ≥ 1. A confirmation arriving on bar maxCandles + 1 or later will be ignored.

Inputs & Outputs

PortTypeDescription
Inputs
input1 (A)(number | null)[]Trigger signal. A value of 1 opens the waiting window.
input2 (B)(number | null)[]Confirmation signal. A value of 1 within the window fires the output.
Outputs
values(number | null)[]1 at bars where a trigger was confirmed within the window; 0 everywhere else.
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values

Use Cases

Two-event confirmation entry

Connect a Crossover signal to Input A (the setup) and a Compare signal (e.g. RSI > 50) to Input B (the confirmation). Only enter when the confirmation follows within 5 bars of the crossover — filtering many false setups that never gain follow-through.

Breakout with close confirmation

Trigger on a price-above-resistance event (Input A) and confirm on a higher-high close the following bar (Input B) with maxCandles = 2. Reduces whipsaw entries caused by intrabar breakouts that reverse before the candle closes.

Pattern + volume confirmation

Feed a candlestick pattern signal (e.g. Bullish Engulfing) to Input A and a volume-above-average signal to Input B. The Wait node fires only when volume confirmation follows the pattern within the allowed window, improving pattern reliability significantly.