STRASMORE/EXPLORE 2,225 QUERIES

window

Answered against 22 years of US equities and 12 years of US options data and published with the query that produced it. This result is stored as of 2026-09-13, from can-a-death-cross-be-bullish.

as of scalar 1×11read in context →
first session
Sep 10, 2003
last session
Sep 11, 2026
session count
5,788
median off high pct
10.2
min off high pct
5.2
max off high pct
22.7
death cross count
11
golden cross count
11
min sessions to golden
37
median sessions to golden
77
max sessions to golden
377
Rows × columns
1 × 11
Computed
Completeness
No missing values
Source
US exchange, SIP and OPRA market data
Licence
Strasmore terms · free, no signup
Formats
JSON · CSV · the SQL below

What each column holds

Column definitions for window, derived from the stored result.
ColumnTypeRangeNotes
first_session text 1 distinct value (Sep 10, 2003)
last_session text 1 distinct value (Sep 11, 2026)
session_count number every row is 5,788 count
median_off_high_pct number every row is 10.2 percent
min_off_high_pct number every row is 5.2 percent
max_off_high_pct number every row is 22.7 percent
death_cross_count number every row is 11 count
golden_cross_count number every row is 11 count
min_sessions_to_golden number every row is 37
median_sessions_to_golden number every row is 77
max_sessions_to_golden number every row is 377

Computed from Strasmore's warehouse of US exchange, SIP and OPRA market data. Equity prices are delayed; options greeks and implied volatility are end-of-day. This result is stored, not recomputed on load — it is exactly the numbers that were returned on , and the query below is what returned them.

the exact SQL behind every number
WITH
bars AS
(
    SELECT
        date,
        toFloat64(argMax(close, _ingest_time)) AS px
    FROM global_markets.stocks_daily_aggs
    WHERE ticker = 'SPY'
    GROUP BY date
),
smas AS
(
    SELECT
        date,
        px,
        row_number() OVER (ORDER BY date) AS rn,
        avg(px) OVER (ORDER BY date ROWS BETWEEN 49 PRECEDING AND CURRENT ROW) AS avg_50,
        avg(px) OVER (ORDER BY date ROWS BETWEEN 199 PRECEDING AND CURRENT ROW) AS avg_200,
        max(px) OVER (ORDER BY date ROWS BETWEEN 251 PRECEDING AND CURRENT ROW) AS high_1y
    FROM bars
),
states AS
(
    SELECT
        *,
        (avg_50 < avg_200) AS below,
        lagInFrame((avg_50 < avg_200), 1) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS prev_below
    FROM smas
),
flags AS
(
    SELECT
        *,
        (rn >= 201 AND below = 1 AND prev_below = 0) AS is_death,
        (rn >= 201 AND below = 0 AND prev_below = 1) AS is_golden
    FROM states
),
events AS
(
    SELECT date, rn, is_death
    FROM flags
    WHERE is_death OR is_golden
),
paired AS
(
    SELECT
        rn,
        is_death,
        leadInFrame(rn, 1) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS next_rn
    FROM events
),
cross_stats AS
(
    SELECT
        countIf(is_death)                                                           AS death_cross_count,
        countIf(NOT is_death)                                                       AS golden_cross_count,
        minIf(toInt64(next_rn) - toInt64(rn), is_death AND next_rn > 0)            AS min_sessions_to_golden,
        quantileExactIf(toInt64(next_rn) - toInt64(rn), is_death AND next_rn > 0)  AS median_sessions_to_golden,
        maxIf(toInt64(next_rn) - toInt64(rn), is_death AND next_rn > 0)            AS max_sessions_to_golden
    FROM paired
),
span AS
(
    SELECT
        concat(formatDateTime(min(date), '%b'), ' ', toString(toDayOfMonth(min(date))), ', ', toString(toYear(min(date)))) AS first_session,
        concat(formatDateTime(max(date), '%b'), ' ', toString(toDayOfMonth(max(date))), ', ', toString(toYear(max(date)))) AS last_session,
        count()                                                        AS session_count,
        round(quantileExactIf((1 - px / high_1y) * 100, is_death), 1)  AS median_off_high_pct,
        round(minIf((1 - px / high_1y) * 100, is_death), 1)            AS min_off_high_pct,
        round(maxIf((1 - px / high_1y) * 100, is_death), 1)            AS max_off_high_pct
    FROM flags
)
SELECT *
FROM span, cross_stats

Run your own version of this

The same 22 years of US equities and 12 years of options data are queryable in SQL or plain English. A free account runs 100 queries a day and takes no card.

More from this analysiscan-a-death-cross-be-bullish
covid_2020 scalar 1×16 trace_2020 series 126×4 whipsaw ranking 11×4 death_crosses table 11×6 forward_record table 4×9 Forward-declared ex-dividend records on file: the receipt behind this calendar scalar 1×5 See all 2,225 queries →