On this page
Overview
In this tutorial I build a Santa Claus rally backtester for ThinkOrSwim to put the idea to a test: has the market tended to rise in the week before Christmas? The strategy buys at the open of the first bar on or after December 18 and sells at the close of the first bar on or after December 24, every year on the chart.
Then I use the strategy report to look at the Decembers inside two bear markets, 2000 to 2002 and 2008. The backtester is 4 lines of thinkScript with no inputs, so it suits beginners, and you can change its two dates to test another window inside a single month.
Key Takeaways
- The Santa Claus rally backtester is a free ThinkOrSwim strategy that buys at the open of the first bar dated December 18 or later and sells at the close of the first bar dated December 24 or later, 1 share per trade.
- The December 18 start comes from the Investopedia description I use in the video, which places the Santa Claus rally in the week before Christmas. The exit is December 24 because the market is closed on the 25th.
- In the video, on SPY, the strategy's P/L was negative over 5 years (5 Decembers), fluctuated over 10 years, was a small positive over 20 years, and stayed positive on the maximum data, which I believe reaches back into the 1990s. No dollar totals are read out.
- In the bear market Decembers on SPY, 2000 and 2001 were positive, 2002 was negative and 2008 was a much deeper negative: 2 positive and 2 negative out of 4.
- For December 2021, the report showed an entry at $454.48 and an exit at $477.26, which matched the open and close on the chart.
What Is the Santa Claus Rally?
The Santa Claus rally is a seasonal tendency for stocks to rise around Christmas, and definitions of the window differ. The best-known one, from the Stock Trader's Almanac, covers the last 5 trading days of December and the first 2 trading days of January. In the video I work from a snippet from Investopedia and test the week before Christmas instead.
Two points stand out in that snippet. First, the rally takes place in the week prior to December 25, and a week before Christmas is December 18, which becomes the start date. Second, it describes the strategy as having had a small positive average return.
A positive average return would imply a positive expectancy, and that's the part worth testing. The Santa Claus rally backtester asks two questions. Does the rally happen more often than not? And what would the P/L have been if you had bought a week before Christmas and sold right before it, year in and year out?
The Santa Claus Rally Rule
The Santa Claus rally backtester has one entry date and one exit date, and both are written the same way: the first bar on or after a day in December. The table lists every part of the rule in the download.
| Part of the rule | Setting in the download |
|---|---|
| Entry bar | The first bar dated December 18 or later (day of month greater than 17) |
| Entry price | The open of that bar |
| Exit bar | The first bar dated December 24 or later (day of month greater than 23) |
| Exit price | The close of that bar |
| Direction | Long only, since the Santa Claus rally is a bullish idea |
| Size | 1 share per trade |
| Trades | 1 per December on the chart |
The exit uses December 24 because the market is closed on the 25th. When the 24th has no bar, the exit moves to the next trading day. That happened in 2021, when the bar after December 23 was December 27.
How to Build the Backtester in ThinkOrSwim
The Santa Claus rally backtester has no inputs, so the whole build is a new strategy with 4 lines in it:
- Click the Studies icon on your chart.
- Click the Strategies tab, then click Create.
- Give the strategy a name. I called mine TI_SantaClausRallyBacktester.
- Delete the starter code and paste in the code from the Code tab on this page.
- Click OK and apply it to a daily chart of SPY. Set the chart's time span to the history you want to test.
The download has the same 4 lines as a .ts strategy file. If you'd rather import it, our guide on how to import a thinkScript file into ThinkOrSwim shows each step.
How the Code Works
The Santa Claus rally backtester code has 2 date conditions and 2 orders. The logic follows the same framework as our Starbucks holiday drinks backtest: a start date, an end date, and care over which price each order uses.
Step 1: The Entry Condition
This step’s code is free with an account. Create one or sign in.
Three built-in thinkScript functions do the work here:
getYYYYMMDD()returns the date of the current bar.getDayOfMonth()takes a date and returns its day of the month as a whole number, such as 17 or 18.getMonth()returns the month of the current bar, and December is 12.
Feeding the bar's date into getDayOfMonth means you don't have to type a date for every December of the past 20 years. A day greater than 17 means the 18th or later, so entry is true on every December bar from the 18th to the end of the month.
Step 2: The Exit Condition
This step’s code is free with an account. Create one or sign in.
The exit condition is the same line with 23 in place of 17. It is true on every December bar from the 24th onward.
Step 3: The Orders
This step’s code is free with an account. Create one or sign in.
AddOrder places the simulated trades. The buy order needs entry to be true on the current bar and false on the previous one, written !entry[1]. That picks out the first bar of the window, so the strategy buys once per year at that bar's open, for 1 share.
The sell order uses the same test on exit and sells to close at the close of the first bar dated the 24th or later. The strategy has no short orders, because the Santa Claus rally is a bullish idea.
Checking the Entry and Exit Prices
The Santa Claus rally backtester fills at the open of the entry bar, while ThinkOrSwim draws the pink strategy marker on the next bar. In the video I checked the December 2021 trade with Show report, which you open by right-clicking on the chart.
- Entry. The report listed the entry on December 21, 2021 at $454.48. That price is the open of the December 20 bar, the first bar after December 17, so the strategy used the right bar. The triangle on the chart marks the actual entry price.
- Exit. The report showed $477.26, the close of the December 27 bar. The bar before it was December 23, so the 27th was the first bar dated the 24th or later.
Run this check on any backtester you build. A strategy that uses the wrong bar's price can show a P/L that no one could have traded, which is the bug I fix in the SPY meltdown backtester video.
Results From the Video
The Santa Claus rally backtester produced these results on daily SPY charts in the video. I most likely recorded it in December 2022: the newest trade I check is December 2021, and I talk about the December ahead. They are historical results for 1 share per trade. The video reads the direction of the P/L for each time span but no dollar totals and no win rate.
| Symbol | Time span | Decembers (trades) | Strategy P/L in the video |
|---|---|---|---|
| SPY | 5 years | 5 | Negative |
| SPY | 10 years | Not stated | Fluctuated. No final figure read out. |
| SPY | 20 years | Not stated | Positive, a small positive |
| SPY | Maximum data, back into the 1990s, I believe | Not stated | Positive |
The 20-year span is the same two decades I believe Investopedia was referring to, and there the small positive result lines up with its description. Over 5 years, the negative P/L told me not to count on a positive expectancy heading into that December, based on those 5 data points.
On the maximum data, the P/L stayed positive. Scrolling back, the strategy worked for most of the early years until it stopped working, which accounts for much of the P/L, and lately it has been climbing back up. The same test runs on QQQ or any other symbol you load.
The Bear Market Decembers
The bear market Decembers on SPY split 2 and 2 in the video. I opened the report on the maximum data and looked at the two bear markets that have data available. I only looked at whether each December's P/L was positive or negative.
| December | Bear market | Santa Claus rally P/L |
|---|---|---|
| December 2000 | 2000 to 2002 | Positive |
| December 2001 | 2000 to 2002 | Positive |
| December 2002 | 2000 to 2002 | Negative |
| December 2008 | 2008 | A much deeper negative |
In the 2000 to 2002 bear market, the rally held in 2 of 3 Decembers. Counting 2008, the 4 bear market Decembers split 2 positive and 2 negative, and I said in the video that this didn't make me optimistic about a Santa Claus rally that year. Four Decembers is a small sample, so read it as context.
How I Read the Results
The Santa Claus rally backtester gave me one input for my bias that December, alongside the chart. SPY was near the top end of a longer-term downtrending channel that I had been following for some time. There was a recent uptrend, but the larger trend was still down, and up toward a previous high I was watching for sellers to come in and push price lower.
With the bearish read on the chart, the negative 5-year result and the split bear market Decembers, I was looking at that December through bearish goggles. The backtest describes past Decembers. It's a read on the season and not an entry signal by itself. Decide where your stop goes before you enter, and size the position so a stop-out costs a small, fixed share of your account.
Changing the Dates or the Market
The Santa Claus rally backtester's dates sit in the two conditions, so you change them in the code. The table shows what to edit.
| To test | Change in the code |
|---|---|
| A later entry, such as December 20 | Change 17 to 19 in entry |
| A later exit, such as December 28 | Change 23 to 27 in exit |
| A window in another month | Change the 12 in both conditions to that month's number |
| Another market | Load the symbol on a daily chart. No code change. |
Keep the entry day smaller than the exit day and both conditions in the same month, or the strategy can't close each trade inside the window.
For a wider view of the calendar, our Seasonal Analysis indicator shows how often each month has closed higher and its average change. Our other free event tools use different triggers:
- The SPY meltdown backtester triggers on price instead of the calendar. It buys the open after a day that closes more than 3% below its open.
- The election backtester swaps the day-of-month test for a list of exact dates, 6 election days, and exits a set number of bars later.
- The Super Bowl indicator is a study, not a strategy. It labels each year with the Super Bowl winner's conference and that year's change.
Our research on S&P 500 November seasonality patterns in bear markets covers the month before December, and the full list of strategies is on our ThinkOrSwim backtesters page.
The backtester on real data
Drawn from real daily bars with the code on this page, through Oct 20, 2026. The backtester buys 1 share at the open of the first bar dated December 18 or later and sells at the close of the first bar dated December 24 or later. Our daily bars start in November 2015, so these are the 11 Decembers from 2015 to 2025; the video went back to the 1990s.
SPY, December 2025

Every December in our data, SPY
| Year | Bought | Open | Sold | Close | Per share |
|---|---|---|---|---|---|
| 2015 | Dec 18 | $202.77 | Dec 24 | $205.68 | +$2.91 (+1.44%) |
| 2016 | Dec 19 | $225.25 | Dec 27 | $226.27 | +$1.02 (+0.45%) |
| 2017 | Dec 18 | $268.10 | Dec 26 | $267.19 | -$0.91 (-0.34%) |
| 2018 | Dec 18 | $257.20 | Dec 24 | $234.34 | -$22.86 (-8.89%) |
| 2019 | Dec 18 | $320.00 | Dec 24 | $321.23 | +$1.23 (+0.38%) |
| 2020 | Dec 18 | $370.97 | Dec 24 | $369.00 | -$1.97 (-0.53%) |
| 2021 | Dec 20 | $454.48 | Dec 27 | $477.26 | +$22.78 (+5.01%) |
| 2022 | Dec 19 | $383.47 | Dec 27 | $381.40 | -$2.07 (-0.54%) |
| 2023 | Dec 18 | $470.98 | Dec 26 | $475.65 | +$4.67 (+0.99%) |
| 2024 | Dec 18 | $603.98 | Dec 24 | $601.30 | -$2.68 (-0.44%) |
| 2025 | Dec 18 | $677.60 | Dec 24 | $690.38 | +$12.78 (+1.89%) |
SPY rose in 6 of the 11 Decembers. December 2021 matches the strategy report in the video: in at $454.48, out at $477.26.
Four index ETFs
| Fund | Up years | Average | Any 5-day stretch, same years |
|---|---|---|---|
| SPY | 6 of 11 | -0.05% | 60%, average +0.23% |
| QQQ | 6 of 11 | -0.28% | 59%, average +0.33% |
| DIA | 7 of 11 | -0.16% | 57%, average +0.19% |
| IWM | 7 of 11 | +0.02% | 53%, average +0.15% |
Per-share results, dividends and commissions left out. The last column is every 5-trading-day stretch (open to close) in the same years, the yardstick for whether the week before Christmas stands out.
Full thinkScript code
Create a free account or sign in to copy all 10 lines and download the file.
Download
Download the Santa Claus Rally Backtester for ThinkOrSwim. The download is a .zip with one strategy file, TI_SantaClausRallyBacktesterSTRATEGY.ts, the same code as the Code tab on this page. Import it as a strategy and apply it to a daily chart, then right-click and choose Show report to see each December trade. If you haven't imported a file before, here's how to import into your ThinkOrSwim platform.
Questions
What is the Santa Claus rally?
The Santa Claus rally is a seasonal tendency for stocks to rise around Christmas. The best-known definition, from the Stock Trader's Almanac, covers the last 5 trading days of December and the first 2 of January. In the video I use an Investopedia snippet that places it in the week prior to December 25, so the backtester tests December 18 to December 24.
How do I backtest the Santa Claus rally in ThinkOrSwim?
Create a strategy: click the Studies icon, open the Strategies tab and click Create. Paste in the 4 lines from the Code tab, click OK and apply it to a daily SPY chart. Right-click and choose Show report to list every December trade, and change the chart's time span to test 5, 10 or 20 years.
Does the Santa Claus rally happen every year?
No. In the video, December 2002 and December 2008 were both negative on SPY, and the strategy's P/L was negative over the past 5 years, or 5 Decembers. Over 20 years it was a small positive, and on the maximum data, which I believe reaches into the 1990s, it stayed positive. These are historical results for 1 share, with no dollar totals read out.
How did the Santa Claus rally do in bear markets?
In the video, on SPY, December 2000 and December 2001 were positive, December 2002 was negative, and December 2008 was a much deeper negative. That is 2 positive and 2 negative out of 4 bear market Decembers, a small sample that I used as context for my bias that December.
What dates does the Santa Claus rally backtester use?
It buys at the open of the first bar dated December 18 or later and sells at the close of the first bar dated December 24 or later. The code tests for a day of the month greater than 17 and greater than 23 in month 12. When December 24 has no bar, the exit moves to the next trading day.
How do I change the dates in the Santa Claus rally backtester?
Edit the numbers in the two conditions. The 17 in the entry line sets the start, so 19 makes the entry the first bar on or after December 20. The 23 in the exit line sets the end, and the 12 in both lines is the month. Keep the entry day smaller than the exit day.
Why does the report show the entry a day after the entry bar?
ThinkOrSwim draws the strategy marker on the bar after the signal, while this backtester fills at the open of the signal bar. In the video, the report listed the December 2021 entry on December 21 at $454.48, which is the open of the December 20 bar. The triangle on the chart marks the actual entry price.
Can I run the Santa Claus rally backtester on QQQ or other stocks?
Yes. The strategy runs on whatever symbol is on the chart, so you can load QQQ or any stock on a daily chart and read the same report. In the video I run the results on SPY and point to QQQ as the next market to try. How far back the test goes depends on how much daily history ThinkOrSwim has for that symbol.
Get each new indicator by email
One email on Sundays with the week's new tool and its code. A free account also unlocks every .txt download.
No credit card. Unsubscribe anytime.
Fair Value Gap
False Breakout Scanner
Heiken Ashi Trend



Stock Volatility Box
Futures Volatility Box
ORB Setups
Squeeze Setups
Super Bowl Indicator
Post-Election Backtester
Seasonal Analysis
SPY Meltdown Backtester
TTM Squeeze Histogram Backtester
Moving Average Pullback Backtester