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
- Wire 2+ moving averages (e.g. SMA 20 / SMA 50 / SMA 200) into the single input.
- Run — fast/slow are picked by window automatically.
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 signAssumptions & 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
- Needs ≥ 2 usable MA inputs, else
signal = none. - Only the smallest- vs largest-window pair is crossed; middle lines are drawn but not crossed.
- 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.

