Sign

Element-wiseCore Math

The Sign node returns the sign of each value: +1 for strictly positive, -1 for strictly negative, and 0 for zero. It is the primary tool for extracting directional information from a numeric series — turning a momentum indicator, MACD histogram, slope output, or price-minus-MA difference into a binary direction series for threshold-crossing logic.

Algorithm

  • output[i] = Math.sign(input[i]) → −1 | 0 | +1
  • null inputs → null output

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

Use Cases

Crossover Detection

Feed the difference (price − MA) into Sign. When Sign flips from −1 to +1 you have a bullish crossover; from +1 to −1 is bearish.

Momentum Direction

Apply Sign to the Slope or Momentum node output to reduce a continuous trend signal to a clean +1/−1 direction flag.

Agreement Scoring

Multiply the Sign outputs of two independent indicators — the product is +1 if they agree and −1 if they disagree, providing a binary consensus signal.