Moving-average crossover screener: golden, death and custom crosses
A moving average crossover screener finds symbols where a faster average changes sides relative to a slower average. A golden cross uses the daily 50-period SMA crossing above the 200-period SMA; a death cross reverses that rule. Specify the average type, bar timeframe and event window before comparing results. Being above an average today does not establish when a cross occurred.
Screen, then verify the event
What Pineify can show before chart review
Market Screener has SMA 50, SMA 200 and configured EMA fields for supported symbols. Compare those readings in a collection, then use the matching TradingView chart to establish the crossover date.
- Available averages
- SMA 50 and SMA 200 describe the selected timeframe. EMA 20, EMA 50 and EMA 200 provide a different weighting of price history.
- Daily interpretation
- Select 1d for a 50-day/200-day comparison. A 50-period average on an hourly chart measures hourly bars, so it answers a different question.
- Freshness check
- Check the collection timestamp and whether the daily candle is still open. A refreshed reading is not evidence of a completed daily crossover.
- Custom event rules
- For an unsupported pair or a bars-since-cross condition, describe the rule to Pine Script AI Coding Agent and review its generated script on a finite symbol list.
Current average values alone cannot establish a recent crossover. This guide does not claim Market Screener provides an arbitrary historical crossover-window filter.
Key Takeaways
- Use the same symbol feed, timeframe, price source and adjustment settings for both averages.
- An upward cross requires the fast average to be above the slow average now and at or below it on the preceding bar.
- A five-bar window includes a cross on the latest completed bar or any of the preceding four completed bars.
- Treat missing history as unknown. Do not replace absent moving-average values with zero.
Choose the average type, lengths and source
An N-period SMA is the sum of the latest N source values divided by N. An EMA gives more weight to recent observations: its update is previous EMA + alpha × (current source - previous EMA), with alpha = 2 / (N + 1). The EMA also depends on its initialization and earlier history. Fix the source to close and the chart offset to zero when reproducing the examples here.
- Golden cross: daily SMA 50 crosses above daily SMA 200.
- Death cross: daily SMA 50 crosses below daily SMA 200.
- Custom cross: write both types and lengths explicitly, such as daily EMA 20 above daily EMA 50. This is not the same rule as a 50/200 SMA golden cross.
- Price crossing SMA 200 compares price with one average. It is a separate condition from two averages crossing.
Separate a continuing state from a new event
Let F be the fast average and S the slow average. The state F > S can stay true for many bars. An upward event requires F > S on the current completed bar and F <= S on the previous completed bar. A downward event requires F < S now and F >= S previously. Equality on the previous bar qualifies; equality on the current bar does not. Compare unrounded values, because two displayed values of 100.00 may differ underneath.
- Fast above slow on both bars: above-state, no new upward event.
- Fast equal to slow previously, then strictly above: upward event.
- Fast below previously, then only equal: no upward event yet.
- A cross during an open daily candle can disappear before the close. Keep provisional and confirmed results separate.
A reproducible 50/200 golden-cross example
Assume a synthetic series in dollars: 199 consecutive daily closes at $100, followed by $90, then $120. At the $90 close, SMA 50 = (49 × 100 + 90) / 50 = $99.80 and SMA 200 = (199 × 100 + 90) / 200 = $99.95. At the next $120 close, SMA 50 = (48 × 100 + 90 + 120) / 50 = $100.20 and SMA 200 = (198 × 100 + 90 + 120) / 200 = $100.05. The fast average changed from below to above, so the last bar contains an upward cross. These invented prices demonstrate the arithmetic, not a trade or performance result.
- Previous spread: $99.80 - $99.95 = -$0.15.
- Current spread: $100.20 - $100.05 = +$0.15.
- If the fast average stays above on the next bar, the state continues but the event age becomes one bar.
- Reverse the two-bar inequality for a death cross; do not merely select all stocks currently below their slow average.
Define what a fresh signal means
For this workflow, event age zero means the cross occurred on the latest completed bar. A recent-five-bar rule accepts ages 0, 1, 2, 3 and 4, and rejects age 5. Count trading bars rather than calendar days: weekends and exchange holidays do not add daily bars. A five-bar rule is a research setting, not a claim that every cross remains useful for five bars.
- Record the cross date and age next to the symbol, rather than relying on an above/below label.
- Decide whether a recent upward cross must still have F > S now. A recent-event-only rule can retain a symbol that has already crossed back down.
- Use the most recent qualifying event when several crosses occur in the window.
- Repeated opposite crosses describe whipsaw. A longer window retains more old signals and does not remove this risk.
Check adjustments and history before accepting a match
Corporate actions and data coverage can change the averages. Compare both series on the same split-adjustment basis and use the same dividend-adjustment setting when checking another chart. TradingView offers dividend adjustment for supported assets. A mismatch can move a crossover date even when the formulas are identical. Do not interpret a price discontinuity from inconsistent adjustment as a market move.
- A 200-period SMA needs 200 valid observations. Proving a new 50/200 event needs valid slow averages on two consecutive bars, so a continuous series needs at least 201 closes.
- To evaluate every event in a five-bar window using a 200-period SMA, retain at least 205 consecutive valid closes, including the preceding comparison bar.
- A newly listed stock with 150 daily closes cannot establish a full 200-day SMA under this rule. Label it insufficient history.
- A holiday without a scheduled bar is normal. An unexpectedly missing session, stale quote or suspended symbol requires review; do not silently fill it with zero or carry an old close forward.
- Match exchange, session and bar-close time. Review EMA warm-up separately because two providers can seed the same EMA length differently.
Use Market Screener to build a reviewable shortlist
Choose a supported stock collection in Pineify Market Screener and set its timeframe to 1d. Add SMA 50, SMA 200 and close, or the available EMA fields for the pair you are studying. Review their relative positions and the result timestamp. Open each candidate on TradingView with the same symbol feed and daily settings, then check the two completed bars around the cross. A collection is a defined universe, not proof that every exchange or newly listed stock was scanned.
- Save symbol, exchange, MA type, lengths, source, timeframe, cross date and adjustment setting with the result.
- If you need EMA 13/34 or a last-five-bars rule that the current field picker does not expose, use Pine Script AI Coding Agent to specify a finite-list script with confirmed-bar events and missing-data handling.
- Review the generated script, its supported symbol count and TradingView request limits. Generating a script does not expand it into an unrestricted whole-market scan.
- Inspect spreads and trading activity before considering execution. A crossover describes historical prices and does not establish trade profitability.
Check a screener result
Check 1
Confirm the symbol universe, timeframe, and data timestamp.
Check 2
Open the matching symbol and timeframe, then compare the reading with the original chart data.
Check 3
Record the rule and its invalidation condition before interpreting the candidate.
This page is for information and education, not investment advice. Examples use invented prices to explain calculations. Screening results and historical crossovers do not guarantee future returns. Trading can result in loss. Pineify is an information tool, not an investment adviser. No screener, indicator, or AI system can predict stock prices with certainty or guarantee a return.
Frequently Asked Questions
Does SMA 50 above SMA 200 mean a golden cross happened today?
No. It identifies the current above-state. A new golden cross also requires SMA 50 to have been at or below SMA 200 on the preceding completed daily bar. Check both bars or a verified event timestamp.
How should a death cross screener define its condition?
Use daily SMA 50 below SMA 200 now, with SMA 50 at or above SMA 200 on the previous completed daily bar. Add an explicit event-age window if you want recent crosses rather than only the latest bar.
Can I use EMA or custom periods for crossover screening?
Yes, as a separately specified rule. EMA 20 crossing EMA 50 and SMA 50 crossing SMA 200 use different calculations and histories. Confirm that the screener exposes the chosen fields; otherwise use a reviewed script for a finite symbol list.
How many daily closes does a 50/200 crossover need?
A continuous series needs at least 201 valid closes to calculate both the current and previous 200-period SMA. Checking all possible crosses in the last five completed bars needs at least 205 valid closes. Missing history makes the affected comparisons unknown.
Why does the chart disagree with my crossover screen?
Check the MA type, length, source, timeframe, exchange feed, candle-close status, data timestamp and price adjustments. Dividend settings, split handling, missing observations and EMA initialization can produce different results even for the same ticker.
Does a recent golden cross predict a profitable trade?
No. Moving averages lag price, and a cross can reverse. Assess a complete rule with exits, execution costs and risk limits before interpreting a screen as a trading strategy.