Guides · Updated 2026-11-09 · Backtest and paper results only, not financial advice.
Moving Average Crossover Backtest: A Viral 20/50 SPY Bot Since 2019
A moving average crossover backtest on the S&P 500 shows a strategy that makes money and softens crashes, but trails simply holding the index. A viral 20/50-day crossover bot we tested turned $10,000 into $18,486 (+84.9%) on SPY from 2019-01-02 to 2026-11-09. Buying SPY and doing nothing turned the same $10,000 into $34,046 (+240.5%). The crossover's worst drop was smaller, -28.2% vs -33.7%, but it gave up 156 percentage points of return to get there. Below is every trade, where it helped and where it hurt. All results are backtests or paper trades, not financial advice.
The viral bot we tested
The rules came from a popular X post showing how to build an AI trading bot with Claude in 14 minutes. The strategy itself is old and simple: buy SPY when its 20-day simple moving average closes above its 50-day average, and go to cash when it closes back below. We call it the 14-minute Claude bot. Because the post spelled out the daily 20/50 rule, this is one of our most faithful rebuilds.
We ran it the same way as every bot on the leaderboard: $10,000 to start, signals on the daily close, fills at the next day's open, 0.05% slippage per fill, no commission, and adjusted daily prices from Yahoo Finance. The exact prompt we used is free on the prompts page.
The results vs buy-and-hold
| Ended with | Return | Per year | Worst drop | Sharpe | Trades | |
|---|---|---|---|---|---|---|
| 20/50 crossover bot | $18,486 | +84.9% | +8.1% | -28.2% | 0.69 | 17 |
| Buy and hold SPY | $34,046 | +240.5% | +16.9% | -33.7% | 0.91 | 0 |
Hypothetical backtests from 2019-01-02 to 2026-11-09, $10,000 start, daily bars, next-day fills. Not advice.
Per year, that's +8.1% for the crossover against +16.9% for holding. The crossover was invested only about 74% of the time, so roughly 26% of the days it sat in cash. That cut both the losses and the gains. Even on a risk-adjusted basis it came out behind: its Sharpe ratio, which scores return per unit of bumpiness, was 0.69 vs 0.91 for SPY.
Every trade, in plain numbers
In 7 years the bot closed 17 trades. 10 won and 7 lost, a 59% win rate. That sounds mediocre, but it's how trend-following is supposed to work: lots of small losses, a few big wins.
- Average winner: +10.1%. Average loser: -4.4%.
- Best trade: +27.8%, held from Oct 21, 2020 to Oct 4, 2021.
- Worst trade: -8.5%, from Apr 4, 2022 to May 3, 2022.
- Longest losing streak: 5 losing trades in a row, from Oct 2021 to Mar 2023, costing $3,626 in total.
The bot doesn't use a stop-loss or profit target. Every exit was the crossover itself, so a trade can only end when the 20-day line falls back under the 50-day. With only 17 trades, this is thin evidence either way. A few lucky or unlucky crosses can swing the result a lot.
Where it helped: the 2020 crash
The crossover's best moment was getting out early in the COVID crash. It sold on Mar 4, 2020, before the worst of the fall, and stayed in cash until May 1, 2020. Buy-and-hold SPY's deepest drop in our window came in that crash (Feb 2020 to Mar 2020). The crossover skipped most of it, and the trade it re-entered with, +17.1%, is a big reason it finished in profit.
Where it hurt: the 2022 whipsaws
Moving average crossovers struggle in choppy markets, and 2022 was choppy. SPY kept falling, bouncing and falling again, and each bounce pulled the 20-day line above the 50-day just long enough to buy before the next leg down. That's the 5-trade losing streak above. The crossover's own worst stretch ran from Dec 2021 to Apr 2023, a -28.2% drop. It didn't get back to its old high until Jul 2025, while buy-and-hold SPY recovered from its 2020 crash by Aug 2020. A crossover protects you from long, steady declines. It doesn't protect you from a market that keeps changing its mind.
This is why the textbook signals use slower averages. The famous golden cross is the 50-day crossing above the 200-day, and the death cross is the reverse. Investopedia notes both are lagging signals that often show up after a trend has already turned. A slower pair trades less and gets whipsawed less, but it also gets out of a crash later. We've only tested the viral 20/50 version, so we can't give you numbers for 50/200 yet.
Where the bot stands now
As of 2026-11-09 the backtest is in cash. The S&P 500 closed below its 50-day average on Oct 30, 2026, according to Lance Roberts' Nov 2 market update. That's not the same as a 20/50 cross, and the bot doesn't sell until its 20-day average closes under its 50-day. It's exactly the kind of moment where a crossover either saves you from a slide or sells right before a bounce.
We're also paper trading the bot forward since 2026-10-16, with simulated fills and no real money. So far it's at -4.3% with 1 closed trades. A few weeks of paper trading proves almost nothing, but it checks that the live rules behave like the backtest. Our paper trading guide shows the setup.
How it compares with the other viral bots
Against the other stock-market bots we tested, the crossover holds up well. A viral HMM regime-switching bot kept its worst drop to -11.0% but returned only +90.7%. The multi-asset bot returned +369.8% on daily bars by adding Bitcoin and gold, then lost money on the shorter bars its creator used. The plain 20/50 crossover sits in between: simple, easy to check, and honest about what it is. See all of them on the leaderboard, and our do AI trading bots work? guide for the full picture.
Can ChatGPT or Claude build this bot?
Yes, and it's the best place to start. On Oct 16, 2026 we gave ChatGPT Free (GPT-5.x "Instant" model; exact name not shown) our crossover prompt. Its backtest matched ours exactly: +92.1% vs +92.1%, the same 16 trades, and no look-ahead bug. (Those figures are from the test date, so they differ slightly from today's.) But the script crashed on its very last line because it used a library it never imported, so we graded it Partial. Even a simple bot needs a second check. The full test is in can ChatGPT or Claude build a trading bot?, and our backtesting checklist covers the rules that keep results honest.
If you want to try a crossover bot
- Decide what you want from it. In this test a crossover cut the worst drop and gave up a lot of return. If you'd hold SPY through a crash anyway, it may not be worth it.
- Test the pair you'll actually use. 20/50, 50/200 and every other pair give different trades. Don't try dozens and keep the best one; that's curve-fitting.
- Count the trades. 17 trades in 7 years is a small sample. Look at the losing streaks, not just the total.
- Paper trade first. The broker AI tracker shows which brokers let a bot place orders and which have paper modes.
- Check costs if you buy a tool. The tools directory lists sourced prices for AI trading platforms. We haven't tested any of them yet.
The bottom line
A moving average crossover backtest on SPY since 2019 shows a strategy that made +84.9%, sat out much of the 2020 crash, got chopped up in 2022, and finished well behind buy-and-hold's +240.5%. It's a decent seatbelt, not a better engine. These are hypothetical backtests and paper trades of a viral bot we tested, and none of it is financial advice.
FAQ
Does a moving average crossover strategy work?
It works as a risk filter more than a profit engine, at least in our test. A viral 20/50-day crossover bot we tested on SPY turned $10,000 into $18,486 (+84.9%) from 2019-01-02 to 2026-11-09, while buying and holding SPY made +240.5%. Its worst drop was -28.2% vs -33.7%. These are hypothetical backtests, not financial advice.
What is a 20/50 moving average crossover?
You buy when the 20-day simple moving average of the price closes above the 50-day average, and you sell to cash when it closes back below. The 20-day line reacts faster, so the cross is a rough signal that the short-term trend has turned.
Is the 20/50 crossover the same as a golden cross?
No. A golden cross usually means the 50-day average crossing above the 200-day, and a death cross is the reverse. The 20/50 version trades more often and reacts faster. We have backtested the 20/50 version only.
Why did the crossover lag buy-and-hold?
It was in cash about 26% of the time, and it buys after a rally has already started and sells after a fall has already started. In a market that mostly went up, the missed days cost more than the avoided drops saved. 7 of its 17 closed trades lost money.
Can ChatGPT build a moving average crossover bot?
Yes, it's the easiest bot to get right. When we gave ChatGPT the exact rules, its backtest matched ours: +92.1% with 16 trades. But the script crashed on its last line from a missing import, so we graded it Partial. Check AI-written code before you trust it.
Get the weekly receipts. Subscribe free and get the Bot Builder Starter Kit (14-page PDF): 5 tested prompts, a hype-detector checklist, and safe paper-trading rules.
Form not showing? Subscribe on beehiiv
Related guides
- Do AI Trading Bots Actually Work? What 5 Viral Bots Did in Backtests
- Can ChatGPT or Claude Build a Trading Bot? We Graded 5 Prompts
- Which Brokers Let AI Trade for You? Robinhood, Alpaca, IBKR and 12 More
- Is That AI Trading Bot Legit? 10 Red Flags to Check First
- How to Paper Trade an AI Trading Bot: Brokers, Setup and Pitfalls
- Can ChatGPT Trade Stocks for You? What It Can and Can't Do
- How to Backtest a Trading Bot (Free, in Python): A Checklist From 5 Viral Bots
- Do Crypto AI Trading Bots Work? 2 Viral Bots vs Holding Bitcoin
- HMM Regime Switching Strategy: A Viral Bull/Bear Bot Backtested Since 2019
- How Much Do AI Trading Bots Cost? Prices of 54 Tools Compared