OPEN-SOURCE SCRIPT

Golden Cross Engine [Quantum Algo]

193
Golden Cross Engine [Quantum Algo]
====================================================

🔶 OVERVIEW

Golden Cross Engine is a complete golden cross and death cross indicator that goes far beyond marking the moving average crossover: it counts down to the next cross before it happens, grades every cross by quality, measures what golden and death crosses have actually done on the current symbol with honest statistics, and lets every cross marker settle into its real outcome so the chart itself shows which crosses worked and which failed.

The golden cross — the fast moving average crossing above the slow, classically the 50 over the 200 — is one of the most watched events in all of trading, and the death cross is its bearish mirror. Every major cross makes financial headlines. This engine turns that famous event from a headline into a measurable, projectable, and auditable object on your chart.

🔶 WHAT ARE THE GOLDEN CROSS AND DEATH CROSS?

A golden cross occurs when a faster moving average (traditionally the 50 period) closes above a slower one (traditionally the 200 period), signaling that intermediate momentum has overtaken the long-term trend — historically read as the start of a bullish regime. A death cross is the opposite: the fast average crossing below the slow, read as the start of a bearish regime. Because both averages move slowly, the cross itself is a lagging event — which is exactly why this engine adds a convergence countdown that shows the cross forming before it prints.

🔶 WHY THIS SCRIPT IS ORIGINAL

1. The convergence countdown. The engine measures the current slope of both averages and projects their geometry forward, drawing the two converging paths and marking where and when they would meet: "Golden Cross ≈ 9 bars" with the projected price level. It is a projection at current slopes — clearly labeled as such, never a forecast — and it makes the most-watched lagging signal in trading visible in advance. An approach alert fires when the countdown first enters your chosen lead window.

2. Markers that settle into their outcome. Every cross prints in neutral gold, then resolves twenty bars later: the bullish or bearish color if the cross delivered, faded gray if it failed. The chart becomes its own audit trail — scroll back and see the honest history of every cross on the symbol.

3. Per-symbol cross statistics. Using shrinkage-adjusted win rates and Wilson confidence bounds, the engine reports how often golden and death crosses were favorable on this exact symbol and timeframe at five, twenty, and sixty bars, with sample counts and average moves — on every marker's tooltip and in the dashboard. It answers "does the golden cross actually work here" with data instead of folklore.

4. Cross quality grading. Every cross is graded A, B, or C from three observable conditions: elevated volume at the cross, slope steepness of the fast average, and momentum confirmation of price relative to it. Grade A crosses are the full-confluence events.

5. A living regime fill. The zone between the averages breathes: the bullish or bearish tint intensifies as the gap widens and pales as a cross approaches, so regime strength and regime fatigue are visible at a glance. Cross bars flash once.

6. Multi-timeframe cross state. The dashboard shows whether the fast average is above or below the slow on the fifteen-minute, one-hour, four-hour, daily, and weekly timeframes simultaneously — full-stack regime alignment in two compact rows.

🔶 HOW IT WORKS

Averages: Selectable simple or exponential averages at configurable lengths, defaulting to the classic 50 and 200.

Countdown: The engine computes each average's recent slope and solves the convergence geometry. When the averages are approaching within the horizon, it draws both projected paths, the meeting diamond with the bar count, and the projected level. When they are separating, the dashboard reads Diverging.

Statistics: Each confirmed cross records what price actually did five, twenty, and sixty bars later, in the cross's direction, into capped first-in-first-out databases. Win rates are pulled toward fifty percent by pseudo-samples so a thin history cannot display fake confidence, and each rate carries a Wilson lower bound. Crosses are rare events by nature, so sample counts are honest and often small — markers read "collecting history" until the minimum is met.

Outcome settlement: Each marker stores its cross price; twenty bars later it recolors by the realized directional outcome and joins the capped history.

Grading: Volume z-score, normalized slope steepness, and price-side confirmation combine into the A, B, C grade shown on the marker tooltip and dashboard.

Non-repainting: Crosses, grades, and statistics are evaluated on closed bars. The countdown updates on the live bar by design — it is a live projection, and it is labeled as one.

🔶 HOW TO USE IT

1. The natural home is the daily chart of major symbols — indices, large-capitalization stocks, cryptocurrency — where the 50 and 200 cross is the famous event. Intraday charts work identically with proportionally more crosses and deeper samples.
2. Watch the countdown as regime alarm: a shrinking bar count with a steepening fast average means the regime change is forming in front of you.
3. Read the settled history before trusting a fresh cross: a chart full of gray markers is telling you crossovers chop on this symbol; a chart of colored ones is telling you they trend.
4. Use the grade as confluence: an A-grade cross with volume, steep slope, and price confirmation is a different event from a flat, quiet drift-through.
5. Check the timeframe rows: a golden cross on your chart while the daily and weekly already sit bullish is alignment; against them, it is a counter-trend event.
6. The statistics rows are context, not commands — favorable rates describe this chart's history, never the next cross.

🔶 SETTINGS

- Average type and both lengths.
- Countdown: projection toggle, horizon, and approach alert lead.
- Statistics: sample cap, minimum samples to grade, shrinkage strength, Wilson z-score, markers to keep.
- Visuals: all colors, gradient fill toggle, cross-bar flash toggle.
- Themeable dashboard: position, four text sizes, title band, background, frame, grid, and three text colors.

🔶 ALERTS

- Golden Cross / Death Cross — the crossover confirmed at bar close.
- Golden Cross Approaching / Death Cross Approaching — the countdown first entered the alert lead window at current slopes.
- Grade A Cross — a cross fired with full quality confluence.

🔶 FREQUENTLY ASKED QUESTIONS

Does the indicator repaint? No. Crosses, grades, statistics, and marker settlement are evaluated on closed bars. The countdown is a live-bar projection and is explicitly presented as one.

Is the countdown a prediction? No. It is where the averages meet if both keep their current slopes. Slopes change; the countdown updates with them. Its value is showing the event forming, not promising the date.

Why are the sample counts small? Because genuine crosses are rare — a daily chart may produce only a handful in years of data. The engine shows honest small numbers with confidence bounds instead of inventing large ones, and lower timeframes build deeper samples.

Why did an old cross marker turn gray? It failed: twenty bars after that cross, price had not moved in the cross's direction. Gray markers are the audit trail working.

Which lengths should I use? The classic 50 and 200 define the famous event. Faster pairs produce more crosses and richer statistics at the cost of more noise.

🔶 CREDITS

The golden cross and death cross are classical moving-average crossover concepts in the public domain of technical analysis, watched across generations of market participants. The Wilson score interval is by Edwin B. Wilson (1927), and shrinkage estimation is standard public statistics. This script gratefully acknowledges that shared lineage. The convergence countdown and projection geometry, the outcome-settling markers, the per-symbol statistical grading, the living regime fill, and all code in this script are original work — no third-party or open-source script code was reused.

🔶 LIMITATIONS

Moving average crossovers are lagging by construction, and the countdown inherits the assumption of stable slopes. Cross samples are naturally small on higher timeframes; statistics mature with history and faster settings. Volume grading is less meaningful on symbols with unreliable volume reporting. Multi-timeframe rows describe state, not signals. No indicator replaces independent analysis.

🔶 DISCLAIMER

This script is provided strictly for educational and informational purposes. It is not financial advice, an investment recommendation, or a solicitation to buy or sell any financial instrument. Past behavior of any cross, projection, or statistic does not guarantee future results. Trading involves substantial risk. Always do your own research and manage risk independently.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.