# MACD Signals Backtester for ThinkOrSwim

thinkScript tutorial Free Beginner 15 min video Nov 30, 2022 Updated Oct 21, 2026

A MACD signals backtester for ThinkOrSwim: load the built-in MACDStrat and test the MACD up and down arrows by market, time frame and setting.

## Overview

In this video I use the MACD signals backtester that comes with ThinkOrSwim, MACDStrat, to test the MACD up and down arrows as a standalone strategy: buy on every up arrow, then sell and go short on every down arrow. I run it on 5 markets, on daily and 1-hour charts, and with a handful of different MACD settings.

No coding is needed. It's for traders who use the MACD and want to know how its signals have behaved on the market and time frame they trade, and for anyone getting started with backtesting in ThinkOrSwim. It's Part 2 of our MACD series.

## Key Takeaways

- The MACD signals backtester is MACDStrat, a strategy built into ThinkOrSwim. It buys on each MACD up arrow and reverses to a short on each down arrow, on the same bar.

- The arrows print when the MACD histogram crosses zero, which is the bar where the Value line crosses the Avg line.

- I tested 3 things: the market (SPY, QQQ, DIA, MSFT and AAPL on 5 years of daily bars), the time frame and amount of history, and the MACD settings.

- On AAPL 1-hour bars over 180 days at the default 12, 26, 9 exponential settings and a trade size of 1, the strategy report showed 87 trades with a total of 43.62. The P/L on the chart read $48.

- On that chart, a 5-period exponential MACD length was the only settings change I tried that beat the defaults. Slower slow lengths, faster fast lengths and a 50-period simple MACD length all did worse.

## What the MACD Signals Backtester Tests

The MACD signals backtester tests one idea: what happens if the MACD up and down arrows are your only trading signals? MACDStrat buys every time an up arrow prints and sells that position on the next down arrow. On that same bar it reverses, so it plays the short side until the next up arrow.

That makes it an always-in strategy, long or short, with no stops or targets of its own. The question is how well that works on its own, and the answer changes a lot from one market, time frame and setting to the next.

I call this the backtesting rabbit hole. Similar markets can have very different P/L structures, and so can different time frames and settings. There are almost infinite permutations, so structure your tests around your own trading style.

## A Quick MACD Refresher

The ThinkOrSwim MACD has 3 outputs you need for this test. The cyan Value line is the 12 EMA minus the 26 EMA. The Avg line is a 9-period EMA of the Value line, and the histogram is the gap between the two lines.

When the Value line crosses the Avg line, the histogram crosses zero, and that's when the up and down arrows print. A cross up is an up arrow, and a cross down is a down arrow. Our [MACD explained tutorial](https://tosindicators.com/thinkscript/macd-explained) (Part 1) breaks down each line and proves the math with code.

## How to Load the MACD Backtester in ThinkOrSwim

The MACD backtester loads like any study, from the Strategies tab. These are the steps I followed in the video:

- Click the Studies icon and switch to the Strategies tab.

- Search for MACDStrat and double-click it to add it to your chart.

- Switch to the studies list and double-click MACD to add the indicator too, so you can see the arrows.

- Make sure the MACD settings line up with what the backtester is using: 12, 26, 9 and exponential.

- Set show breakout signals to Yes on the MACD, then click Apply.

- If you don't see the P/L histogram below the chart, click Global strategy settings and check it on. I also set the default trade size to 1 there. Click OK twice.

- To see each trade, right-click and choose Show report.

The table is the setup I used for every test in the video, unless a section says otherwise.

Setting Value in the video

Strategy MACDStrat (built into ThinkOrSwim)

Fast length / slow length / MACD length 12 / 26 / 9

Average type Exponential

MACD study Same settings, show breakout signals on

P/L histogram On (Global strategy settings)

Default trade size 1

## Why I Set the Trade Size to 1

A trade size of 1 is a deliberate choice for this kind of test. It makes it easier to ignore the P/L numbers and the glamour of a big total, and to focus on two things: is the P/L positive or negative, and what did the journey to get there look like?

The P/L histogram is a perk of strategies in ThinkOrSwim. It gives you a quick gauge of whether an idea has a positive or a negative trade expectancy on the market, time frame and setting you're testing. I read its shape as much as its last value.

## Test 1: The Same Signals on 5 Markets

The first MACD backtest compares markets. I ran the default settings on daily charts going back 5 years on SPY, QQQ, DIA, Microsoft and Apple. The video doesn't show trade counts for these runs, so the table describes each result without the dollar totals.

Market (daily, 5 years) P/L at the end How it got there

SPY Positive Long stretches of negative P/L that lasted several months

QQQ Negative A negative story the whole way

DIA A little positive A negative story, nothing to care about

MSFT Deep negative Doing the opposite of the signals would have worked better

AAPL Positive A P/L graph that climbed consistently

SPY ended positive, but I'm not sure a trader would have stuck with the strategy through those months of negative P/L, so SPY was a no. Microsoft and Apple are similar names, yet over the same period Apple had a much better story. Out of the 5 markets, Apple was the one that looked most intriguing, so the next two tests use it.

## Test 2: Time Frames and History on Apple

The second MACD backtest changes two things you control: how much history the chart loads, and the time frame of each bar. Pick the ones that match how you trade. If you trade monthly options, a 5-minute backtest may not matter to you, but a 1-hour or 4-hour chart might.

On the 5-year daily chart, Apple's P/L was positive and climbing. Narrowing the chart to 1 year, which started in December 2021, showed how the strategy did through that bear market. The P/L was still positive at the end, but it went negative along the way.

The report for that 1-year run started with a loss and included a large loss and two back-to-back losses. A few big winners kept the strategy afloat. On both the 5-year and the 1-year daily charts, the overall P/L was positive, and the 5-year chart was the backtest I liked.

Then I zoomed in to the 1-hour time frame, going back 180 days, for more trade opportunities. The 1-hour run is the only one in the video with a trade count.

AAPL, 1-hour bars, 180 days In the video

Settings 12, 26, 9, exponential, trade size 1

Trades in the strategy report 87

Total at the bottom of the report 43.62

P/L shown on the chart $48

A winner I pointed out About $16

Biggest loss I found while scrolling (there may be more) About $8

The losses were much smaller than the winners, and the P/L histogram showed the strategy hadn't given you a lot of heat on Apple's 1-hour chart. That makes it a strategy you could follow mentally and emotionally, compared with some of the other charts I tested. These are historical results from the video, a few months of one stock, and they say nothing certain about the next 87 trades.

## Test 3: Changing the MACD Settings

The MACD has 4 settings that change the backtest: the fast length, the slow length, the MACD length, and the average type. I stayed on the Apple 1-hour, 180-day chart and compared each change with the default P/L of $48. The video doesn't show trade counts for these runs, so the table ranks them against the default.

Fast / slow / MACD length, type What I changed P/L compared with the default

12 / 26 / 9, exponential Nothing: the default Baseline

12 / 38 / 9, exponential Slower slow length Lower

12 / 50 / 9, exponential Slower still Lower again

3 / 26 / 9, exponential Faster fast length Lower

8 / not clear / 9, exponential Fast length of 8 Higher than the 3, still below the default

12 / 26 / 50, simple Much slower MACD length, simple average Deep negative

12 / 26 / 5, exponential Faster MACD length Highest of all the tests, above the default

Raising the slow length lowered the P/L each time, so making it slower didn't help. Dropping the fast length to 3 didn't help either. The one change that beat the defaults was a 5-period exponential MACD length.

For the record, I'm not a fan of tweaking settings and playing the settings game, and I find the defaults to be the most ideal. What I do find useful is testing broad buckets, more sensitive against slower and more conservative, to see where on the pendulum the P/L tends to swing.

## How to Read the Results for Your Trading Style

The MACD signals backtester is a starting point for testing, and in a few minutes it covered a lot: 5 markets, 3 chart setups on Apple, a few fast lengths, slow lengths, MACD lengths and two average types. The goal is to get a feel for the personality of these signals on the market you trade.

Read the journey as well as the final P/L. A strategy that ends positive after months below zero is hard to follow in real time. Look for a P/L graph that climbs without much heat, on a time frame you would trade.

Treat the arrows as one input. The backtest has no stop, so decide where yours goes before you take a trade, and size it so a stop-out costs a small, fixed share of your account. All of these figures are historical results from the video, on the dates it was recorded.

## Common Problems With the MACD Backtester

- No P/L histogram under the chart. Open Global strategy settings and check the P/L histogram on.

- The arrows don't match the trades. The MACD study and MACDStrat each have their own settings. Make sure both use the same lengths and average type, and turn show breakout signals on in the study.

- The P/L looks too small or too large. The P/L scales with the default trade size in Global strategy settings. With a trade size of 1, read the sign and the shape of the P/L.

- The chart P/L and the report total differ. In the video the chart read $48 and the report total 43.62 for the same run. Check both, and use the report for the trade-by-trade detail.

## Where to Go From Here

The basic MACD backtester is the first step. In the video I said future parts of the series would layer filters on to make it smarter. The [Smarter MACD](https://tosindicators.com/indicators/smarter-macd) is a later part of the series: one green or red MACD line from a higher time frame. To scan for crossovers, try our [MACD crossover scans](https://tosindicators.com/scans/macd-crossover).

For more strategy tests in ThinkOrSwim, the [backtesters page](https://tosindicators.com/backtesters) lists them all. The [moving average crossover backtester](https://tosindicators.com/backtesters/moving-average-crossover) and the [Squeeze backtester](https://tosindicators.com/backtesters/ttm-squeeze-backtester) are good next steps if you want to write a strategy yourself.

## The backtester on real data

Drawn from real daily bars with the code on this page, through Oct 20, 2026. MACDStrat goes long when the MACD Value line crosses above its Avg line and reverses to a short on the cross below, so it is always in the market. Its orders fill at the next bar's open, ThinkOrSwim's default for a strategy order. 1 share a trade, as in the video, with the last open trade marked at the Oct 20 close.

### SPY since February

SPY since Feb 2, 2026: 13 entries. Cyan arrows are longs, pink arrows shorts. The bars below are the running P/L per share from the chart's first day.

Over those months the strategy finished +$28.62 a share. In ThinkOrSwim the P/L histogram under the chart tells the same story.

### The video's first test, on our data

The video ran the default 12, 26, 9 settings on 5 years of daily SPY, QQQ, DIA, MSFT and AAPL. Our data has the three ETFs for those five years; Microsoft and Apple start in July 2024.

Market, daily First trade Trades Won Total, 1 share Longs / shorts Buy and hold

SPY Nov 18, 2021 107 36% -$131.86 +$83.98 / -$215.83 +$299.81

QQQ Nov 24, 2021 95 35% -$191.53 +$65.58 / -$257.12 +$322.70

DIA Nov 12, 2021 106 32% -$56.81 +$53.43 / -$110.24 +$163.67

MSFT Sep 9, 2024 43 30% -$221.04 -$48.20 / -$172.83 +$124.63

AAPL Sep 5, 2024 40 45% -$4.77 +$56.55 / -$61.32 +$117.88

Per share, dividends and commissions left out. "Buy and hold" is one share bought at the first trade's open and held to the Oct 20 close. The short side is where an always-in strategy pays for a rising market.

## Download

MACD Signals Backtester, a complete breakdown Download MACD Signals Backtester, a complete breakdown for ThinkOrSwim.

[Download free](https://tosindicators.com/thinkscript/macd-signals-backtester)

## Video: MACD Signals Backtester, a complete breakdown, built line by line

15 minutes on YouTube.

[Watch on YouTube](https://www.youtube.com/watch?v=HCjZ4zHO11M)

## Questions

How do I backtest MACD signals in ThinkOrSwim?

Click the Studies icon, go to the Strategies tab, search for MACDStrat and double-click it. Add the MACD study with the same settings, 12, 26, 9 and exponential, and turn on show breakout signals to see the arrows. Turn on the P/L histogram in Global strategy settings, then right-click and choose Show report to see each trade.

What is MACDStrat in ThinkOrSwim?

MACDStrat is a strategy built into ThinkOrSwim that trades the MACD up and down arrows. It buys on each up arrow, sells that position on the next down arrow and reverses to a short on the same bar. It is always in the market, with no stops or targets, which makes it a clean test of the signals on their own.

How do I turn on the P/L histogram for a strategy?

Click Global strategy settings and check the P/L histogram on. It plots below the chart and shows whether the strategy has a positive or negative trade expectancy over the chart. The same window sets the default trade size. I use 1, so I focus on the sign and the shape of the P/L.

What settings did the MACD backtest use?

The default MACD settings: a fast length of 12, a slow length of 26, a MACD length of 9 and an exponential average type, with a default trade size of 1. Make sure the MACD study and MACDStrat use the same numbers so the arrows on your chart match the trades.

Which market did best in the MACD backtest?

Apple. On 5 years of daily bars at the default settings, Apple had the only P/L graph that climbed consistently. SPY ended positive after months of negative P/L, DIA was a little positive, QQQ was negative and Microsoft was deep negative. The video does not show trade counts for those daily runs.

How many trades did the MACD strategy take on the 1-hour chart?

On Apple 1-hour bars over 180 days at the default settings and a trade size of 1, the strategy report showed 87 trades with a total of 43.62, and the chart P/L read $48. One winner I pointed out was about $16, and the biggest loss I found while scrolling was about $8. That is one historical run.

Did changing the MACD settings improve the backtest?

Only one change did. On the Apple 1-hour, 180-day chart, a 5-period exponential MACD length beat the default P/L. Slower slow lengths of 38 and 50, a fast length of 3, a fast length of 8 and a 50-period simple MACD length all did worse. I still prefer the default settings.

Why set the backtest trade size to 1?

A trade size of 1 keeps the P/L small, so you ignore the glamour of a big number and focus on whether the result is positive or negative and what the journey looked like. A strategy that ends positive after months of losses is hard to follow in real time.

## Related tools

[MACD Crossover Near Zero Line: Scan · Free](https://tosindicators.com/scans/macd-crossover)[Smarter MACD: Indicator · Free](https://tosindicators.com/indicators/smarter-macd)[MACD Indicator, a complete breakdown: thinkScript tutorial · Free](https://tosindicators.com/thinkscript/macd-explained)[How to Draw Price Channels: thinkScript tutorial · Free](https://tosindicators.com/thinkscript/price-channels)[Maximize Your Chart Space With This Simple Trick: thinkScript tutorial · Free](https://tosindicators.com/thinkscript/maximize-chart-space)[Build Your Own Automated Text Message Alert System: thinkScript tutorial · Free](https://tosindicators.com/thinkscript/text-alerts)

## 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.
