Skip to content

MA Crossover (Golden / Death Cross)

The headline moving-average crossover building block. Connect one or more moving averages to the single input port — fast/slow are inferred from each line's window (smallest = fast), every line is returned for plotting, and the fastest-vs-slowest pair is crossed. Edge-first, no tunable params.

How to use

  1. Wire 2+ moving averages (e.g. SMA 20 / SMA 50 / SMA 200) into the single input.
  2. Run — fast/slow are picked by window automatically.
  3. signal (golden_cross / death_cross / none) drives a downstream strategy/risk block; the result chart draws every line and marks the cross.

Core formulas

cross_series[i] = sign(fast[i] − slow[i])  in {−1, 0, +1}  (None on warmup)
signal = most recent transition:
  <=0 → >0 : golden_cross
  >=0 → <0 : death_cross
  else     : none
current = latest non-None sign

Assumptions & applicability

Assumptions: inputs are MAs of the same underlying over a common range, each with a window so fast/slow can be ordered; ≥ 2 usable series.

Applicability: any asset class / frequency; ≥ 2 observations.

Out of scope: manual fast/slow assignment, multiple cross pairs per node.

Known limitations

  1. Needs ≥ 2 usable MA inputs, else signal = none.
  2. Only the smallest- vs largest-window pair is crossed; middle lines are drawn but not crossed.
  3. Equal-window ties broken by wiring order (flagged).

References

Murphy (1999), Technical Analysis of the Financial Markets — moving-average crossover.

Golden Test

tests/golden/fixtures/tier1/compute_crossover/ — 1e-9 absolute, independent numpy reference, 2026-05-25 passing. Locks the sign convention, None warmup, the ≤0→>0 / ≥0→<0 boundary, and "most recent cross" (not the first).

Changelog

  • 1.0.0 (2026-05-25) — Initial Active. Single-input-port redesign (was dual series_fast/series_slow handles); fast/slow auto-inferred from window; golden added.

Verifiable intelligence for the decisions that demand scrutiny.