DocsLogicBoolean

Boolean

BinaryLogic

The Boolean node applies a bitwise-style logic gate element-by-element across two aligned signal arrays. Both inputs are treated as boolean — any non-zero value is true. The second input can be replaced by a fixed numeric constant via useNumericB. Null in either input propagates null to the output.

Operations

OperationOutput is 1 whenTypical use
ANDBoth A and B are non-zeroRequire two conditions simultaneously
ORAt least one of A or B is non-zeroFire on any matching signal
XORExactly one of A or B is non-zeroDetect disagreement between two signals
NANDNOT (A AND B) — false only when both are 1Block when both signals are active
NORNeither A nor B is non-zeroDetect combined inactivity
XNORA and B have the same boolean valueDetect agreement between two signals

Algorithm

  • Each value is cast to boolean: val !== 0 → true, val === 0 → false
  • The selected gate is applied to the boolean pair at each index
  • Result is converted back: true → 1, false → 0
  • If either operand is null or undefined, the output is null
  • Arrays are aligned by length — the shorter array determines the output length

Parameters

NameTypeDefaultDescription
operationstringandOne of: and, or, xor, nand, nor, xnor
useNumericBbooleanfalseWhen true, uses numericB as a constant for Input B instead of the second port connection. Disconnects any existing Input B edge.
numericBnumber0Constant value for Input B when useNumericB is enabled. Treated as boolean: 0 = false, non-zero = true.

Inputs & Outputs

PortTypeDescription
Inputs
input1(number | null)[]Input A — primary signal array
input2(number | null)[]Input B — secondary signal array (ignored when useNumericB is true)
Outputs
values(number | null)[]0 or 1 at each bar — result of the selected gate. null where either input was null.
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values

Use Cases

Multi-condition entry (AND)

Connect RSI-oversold signal and price-above-SMA signal into an AND gate. The strategy only fires when both conditions are simultaneously true, reducing false entries.

Alternative signals (OR)

Combine a MACD crossover signal and a Stochastic oversold signal with OR. The strategy triggers on whichever signal fires first, increasing opportunity frequency.

Conflict detection (XOR)

Feed a long signal and a short signal into XOR. The output is 1 only when exactly one direction is active — use it to detect clean directional bias with no conflicting signals.