EMA 12/26 Trend on AGG
iShares Core U.S. Aggregate Bond ETF: the broad US investment-grade bond market in one fund. Backtest 2021-01-04 to 2026-10-02, $10,000 starting capital, computed by the same engine that runs live DeployQuant strategies.
The EMA 12/26 trend rule bought AGG on 22 separate occasions between 2021-01-04 and 2026-10-02 and finished with $10,632 from $10,000. That is 6.32% in total and a 1.07% CAGR. Buy-and-hold of the same fund finished with $9,559, a loss of 4.41% and a CAGR of negative 0.78%. The rule's maximum drawdown was 4.88%. Holding AGG fell 17.57% from the first day of the test to 2022-10-20 and had not recovered by the end of the data.
AGG is the broad US investment-grade bond fund, and in this window it did something unusual for a bond fund: it lost money for nearly the whole test. The rule's job was to avoid some of that. It did, mostly by being in cash during the first half of 2022. Its gain over buy-and-hold came from one year, and it gave some of it back in the two years after.
The result ranks second among the 12 templates on AGG by CAGR, behind the RSI(2) snapback at 1.57%. Across all 59 funds, this strategy's AGG result ranks 36th. The median CAGR for EMA 12/26 trend across all funds was 2.76%, so AGG sits below the typical fund for this rule, and above the 1.02% median for bond funds. The full set of results for the fund is on the AGG page.
The headline run has no fees and no slippage. The window is one stretch of 5.7 years, and the rule decides once a day.
Year by year
| Year | EMA 12/26 trend | buy & hold |
|---|---|---|
| 2021 | −0.8% | −1.6% |
| 2022 | 0.6% | −12.7% |
| 2023 | 5.9% | 5.5% |
| 2024 | −0.9% | 1.3% |
| 2025 | 3.2% | 7.0% |
| 2026 | −1.6% | −2.7% |
How each year played out
The year-by-year table is the most useful view of this result, because the whole gain came from 2022.
In 2021 the rule lost 0.8% and AGG lost 1.6%. The first trade did not start until 2021-04-16, so the rule sat in cash for the first three and a half months. It then made four trades in 2021: a loss of 0.2% in April and May, a gain of 0.8% that lasted 125 days from 2021-05-26 to 2021-09-28, a loss of 1.0% over 8 days in November, and a loss of 0.4% in December. The long trade was the only winner of the year. The three small losses are the typical cost of a trend rule on a flat fund: it enters after a short move up and exits after a short move down.
In 2022 the rule gained 0.6% while AGG lost 12.7%. This is the year that made the result. The rule made no trade from 2021-12-30 until 2022-07-13, so January through June 2022 are all zeros in the monthly table. AGG's worst days in the data cluster in that year: negative 1.63% on 2022-06-13, negative 1.30% on 2022-09-26 and negative 1.23% on 2022-03-02. The rule was in cash for all three. It bought on 2022-07-13 at an adjusted $87.03 and sold on 2022-08-23 at $87.40 for 0.4%. It then bought again on 2022-11-16 at $84.32, after AGG's low on 2022-10-20.
In 2023 the rule gained 5.9% and AGG gained 5.5%. The trade that started on 2022-11-16 ran to 2023-02-15 and returned 1.6%, and the November 2023 entry at $84.30 produced 3.6% by 2024-02-14. A 2023-03-17 entry lost 0.6% and a 2023-07-20 entry lost 0.7% in 8 days. December 2023 was the rule's best month at 3.57%.
In 2024 the rule lost 0.9% while AGG gained 1.3%. The rule's best trade of the whole test came that year, 5.1% from 2024-05-10 to 2024-10-09, and it also had three losers: two of 0.9% in March and one of 1.9% in December. The March trades are a clear whipsaw. It sold on 2024-03-20 at $87.99, bought back on 2024-03-22 at $88.55 and sold again on 2024-04-05 at $87.75.
In 2025 the rule gained 3.2% while AGG gained 7.0%, the year with the largest shortfall. The rule was out of the fund for parts of the spring, selling on 2025-04-14 and buying again on 2025-04-29, then selling on 2025-05-14 after a loss of 1.2%. The 4.0% gain from 2025-06-05 to 2025-11-19 was the main winner.
In 2026 the rule lost 1.6% against 2.7% for AGG, with the year still partial. The rule beat buy-and-hold in 4 of the 6 years: 2021, 2022, 2023 and 2026. It trailed in 2024 and 2025. The 2022 gap was far larger than any other, and the two years it lost were years in which AGG simply rose.
Month by month
| Year | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2021 | 0.0% | 0.0% | 0.0% | −0.0% | −0.3% | 0.9% | 1.1% | −0.2% | −0.9% | 0.0% | −1.0% | −0.3% |
| 2022 | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 2.7% | −2.2% | 0.0% | 0.0% | 1.0% | −0.8% |
| 2023 | 3.4% | −1.9% | 0.4% | 0.6% | −1.6% | 0.0% | −0.6% | 0.0% | 0.0% | 0.0% | 2.0% | 3.6% |
| 2024 | −0.1% | −1.9% | −0.9% | −0.9% | 0.2% | 0.9% | 2.3% | 1.4% | 1.3% | −1.3% | 0.0% | −1.9% |
| 2025 | −0.2% | 2.2% | 0.0% | −0.9% | −1.4% | 1.2% | −0.3% | 1.2% | 1.1% | 0.6% | 0.2% | −0.4% |
| 2026 | 0.2% | 1.6% | −1.6% | −0.6% | 0.0% | 0.1% | −0.7% | −0.5% | −0.2% | 0.0% | – | – |
Reading the monthly table
The monthly table has a lot of zeros, and each one is a month with no position. All of January through June 2022 is flat, as are August through October 2023 and a handful of other months. A month of 0.0% in a long or flat rule means the account was in cash all month.
The best month was December 2023 at 3.57%, a month when AGG rallied hard after the late 2023 low, and the rule already held the position from its 2023-11-08 entry. November 2023 was also strong at 2.0%. The worst month was August 2022 at negative 2.23%, a month in which the rule held the position it bought on 2022-07-13 and watched AGG fall back from its July bounce. Buy-and-hold's worst month was September 2022 at negative 4.07%, and the rule was in cash for it.
The negative months scattered through 2024 and 2025 are small. February 2024 at negative 1.9% and December 2024 at negative 1.9% are the largest. A rule that loses 0.9% on a trade and wins 0.8% on the next one has little room to compound. The strong months are few: July 2021 at 1.1%, July 2022 at 2.7%, January 2023 at 3.4%, November 2023 at 2.0%, December 2023 at 3.6% and July 2024 at 2.3% stand out against a table of small numbers.
AGG's own seasonal averages in this window show November as its best month at 2.08% on average and September as the worst at negative 1.31%. Each calendar month has only 5 or 6 observations, which is far too few to say anything about seasonality. The numbers describe this window.
Every trade
EMA 12/26 trend on AGG made 22 closed round trips, an average hold of 50 days, an average winner of 2.08%, an average loser of −0.72%, a profit factor of 1.62, a longest losing streak of 4. It held a position at the close on 52.7% of trading days.
| Entry | Entry price | Exit | Exit price | Return | Days held |
|---|---|---|---|---|---|
| 2021-04-16 | $96.26 | 2021-05-14 | $96.11 | −0.2% | 28 |
| 2021-05-26 | $96.51 | 2021-09-28 | $97.23 | 0.8% | 125 |
| 2021-11-08 | $97.74 | 2021-11-16 | $96.73 | −1.0% | 8 |
| 2021-12-03 | $97.36 | 2021-12-30 | $97.01 | −0.4% | 27 |
| 2022-07-13 | $87.03 | 2022-08-23 | $87.40 | 0.4% | 41 |
| 2022-11-16 | $84.32 | 2023-02-15 | $85.70 | 1.6% | 91 |
| 2023-03-17 | $86.83 | 2023-05-19 | $86.29 | −0.6% | 63 |
| 2023-07-20 | $86.67 | 2023-07-28 | $86.11 | −0.7% | 8 |
| 2023-11-08 | $84.30 | 2024-02-14 | $87.37 | 3.6% | 98 |
| 2024-03-07 | $88.83 | 2024-03-20 | $87.99 | −0.9% | 13 |
| 2024-03-22 | $88.55 | 2024-04-05 | $87.75 | −0.9% | 14 |
| 2024-05-10 | $87.62 | 2024-10-09 | $92.07 | 5.1% | 152 |
| 2024-12-03 | $92.05 | 2024-12-19 | $90.26 | −1.9% | 16 |
| 2025-01-30 | $91.06 | 2025-04-14 | $91.80 | 0.8% | 74 |
| 2025-04-29 | $93.05 | 2025-05-14 | $91.94 | −1.2% | 15 |
| 2025-06-05 | $92.93 | 2025-11-19 | $96.60 | 4.0% | 167 |
| 2025-11-24 | $96.94 | 2025-12-16 | $96.59 | −0.4% | 22 |
| 2025-12-17 | $96.74 | 2026-03-13 | $97.11 | 0.4% | 86 |
| 2026-04-15 | $97.66 | 2026-05-01 | $97.14 | −0.5% | 16 |
| 2026-06-03 | $97.16 | 2026-06-09 | $96.97 | −0.2% | 6 |
| 2026-06-12 | $97.36 | 2026-07-13 | $96.92 | −0.5% | 31 |
| 2026-08-26 | $97.18 | 2026-09-02 | $96.50 | −0.7% | 7 |
Prices are adjusted for splits and dividends, so they sit below the quotes printed at the time. An open position is marked at the last close.
The 22 round trips
Of 22 round trips, 8 closed at a profit, a win rate of 36%. The average winner returned 2.08% and the average loser lost 0.72%, which gives a profit factor of 1.62. The best trade returned 5.08% over 152 days, from an adjusted $87.62 on 2024-05-10 to $92.07 on 2024-10-09. The worst lost 1.94% over 16 days, from $92.05 on 2024-12-03 to $90.26 on 2024-12-19. The longest losing streak was 4 trades and the longest winning streak was 2.
This is the typical shape of a trend rule: a low win rate, small losers and a few larger winners. The margin on a bond fund is thin. The five best trades returned 5.08%, 3.95%, 3.64%, 1.64% and 0.81%, and only the first three were larger than the average winner of 2.08%.
The median trade lost 0.36% and lasted 28 days, so the usual trade was a small loss that closed inside two months. A trend rule is paid for the occasional move of several percent that lasts for months. AGG delivered three of those in the window: the 2023-11-08 entry, the 2024-05-10 entry and the 2025-06-05 entry. Each took more than 90 days.
The trades cluster after a pause. Four exits in 2026 came in quick succession: 2026-05-01 for negative 0.5%, 2026-06-09 for negative 0.2%, 2026-07-13 for negative 0.5% and 2026-09-02 for negative 0.7%. Each re-entry came after the 12-day average climbed back above the 26-day for a short time, and each time AGG slipped again. The 2026-08-26 entry at $97.18 and the 2026-09-02 exit at $96.50 lasted 7 days. All 22 trades were closed at the end of the data, so no open position is marked at the last close.
Prices on the trade list are adjusted for splits and dividends, and they read lower than the quotes printed at the time.
Largest drawdowns
| Peak | Low point | Depth | Days to low | Recovered | Days to recover |
|---|---|---|---|---|---|
| 2024-09-16 | 2025-06-06 | −4.9% | 263 | 2025-10-20 | 136 |
| 2023-12-27 | 2024-05-29 | −4.7% | 154 | 2024-08-02 | 65 |
| 2023-02-02 | 2023-11-09 | −4.3% | 280 | 2023-12-13 | 34 |
Buy-and-hold's deepest drawdown ran from 2021-01-04 to 2022-10-20 and reached −17.6%.
The three deepest drawdowns
The rule's deepest drawdown was 4.88%, from a peak on 2024-09-16 to a low on 2025-06-06. It took 263 days to reach the low and 136 more to recover on 2025-10-20. The second was 4.70%, from 2023-12-27 to 2024-05-29, recovering on 2024-08-02 after 65 days. The third was 4.26%, from 2023-02-02 to 2023-11-09, recovered on 2023-12-13.
These are shallow, and they are long. A 4.88% drawdown that takes 263 days to bottom is a slow bleed of small losses and not a crash, and it matches the trade list: in the second half of 2024 and the first half of 2025 the rule took the 1.9% loss in December, a 1.2% loss in May and several small ones between its larger winners. Nothing in the three drawdowns came from one bad day.
Buy-and-hold fell 17.57% from 2021-01-04 to 2022-10-20 and had no recovery by 2026-10-02, a stretch that covers the whole test. The longest drawdown for the fund lasted 1,443 of the 1,444 sessions. The rule's maximum drawdown was shallower than holding by 12.69 percentage points. Most of that gap comes from the first half of 2022, when the rule held nothing.
The profile table on the page lists AGG's deepest drawdown as 17.98% on the raw price and the buy-and-hold run as 17.57%. The two differ because the test puts 98% of the account into the fund, which leaves a small cash buffer.
With trading costs
The headline run fills at the bar price. These runs charge slippage on every fill.
| Slippage per fill | CAGR | Max drawdown | Final value | Sharpe |
|---|---|---|---|---|
| None (headline) | 1.1% | −4.9% | $10,632 | 0.30 |
| 5 basis points | 0.7% | −5.3% | $10,411 | 0.20 |
| 10 basis points | 0.3% | −5.6% | $10,187 | 0.10 |
What slippage does to a 1% CAGR
Each fill in the headline run happens at the bar price with no cost. The cost runs charge slippage on every fill. At 5 basis points per fill the CAGR falls from 1.07% to 0.70% and the final value from $10,632 to $10,411. At 10 basis points the CAGR is 0.32% and the final value is $10,187. The Sharpe ratio falls from 0.30 to 0.2 and then to 0.1. The maximum drawdown rises from 4.88% to 5.26% and then 5.63%.
The rule made 44 fills in 5.7 years, so its cost bill is meaningful against a gross gain this small. A bond fund has a tight spread, and AGG's average daily dollar volume was $647,965,164 with a median minute volume of 8,686 shares. A small account will not move that price. Even so, the strategy's edge over buy-and-hold shrank with each cost run, and the 10 basis point run still finished above the buy-and-hold $9,559. The advantage over buy-and-hold survived the costs tested.
Because most of the gain came from one avoided drawdown, the cost runs matter less for the main result than for the second-order one. Costs cannot turn the 2022 effect off. They reduce the small gains from 2023 and 2025 that the rule earned on top.
Changing the parameters
| Version | CAGR | Max drawdown | Round trips | Win rate | Final value |
|---|---|---|---|---|---|
| Published rules | 1.1% | −4.9% | 22 | 36% | $10,632 |
| EMA 8/21 | 0.8% | −5.5% | 35 | 37% | $10,456 |
| EMA 20/50 | 0.9% | −4.6% | 11 | 55% | $10,506 |
| EMA 12/50 | 1.1% | −5.8% | 19 | 32% | $10,676 |
Parameter variants
Three variants change the averages. EMA 8/21 uses a faster pair and made 35 trades, with a CAGR of 0.78%, a maximum drawdown of 5.51% and a final value of $10,456. EMA 20/50 uses a slower pair and made 11 trades, with a CAGR of 0.86%, a maximum drawdown of 4.58% and a final value of $10,506. EMA 12/50 keeps the fast average and slows the long one, and made 19 trades with a CAGR of 1.15%, a maximum drawdown of 5.79% and a final value of $10,676.
The published 12/26 rule sits in the middle at 1.07%. All four results are within a narrow range, between 0.78% and 1.15%, and all four beat buy-and-hold's negative 0.78%. That is the useful finding: the outcome did not depend on the exact pair. A rule that held up only for 12/26 would be a sign of a fitted number, and that does not show here.
The trade counts move more than the returns. The faster pair won 13 of 35, the slower pair won 6 of 11, more than half, and the 12/50 version won 6 of 19. A slower pair makes fewer decisions and fewer small losses, and it also reacts later when AGG turns. On this fund the two effects roughly cancelled.
The test covers four settings, so it cannot rank parameters in general. The 12/50 version had the highest final value and the deepest drawdown of the group at 5.79%, so the best CAGR came with the worst drawdown.
How AGG behaved
| Measure | AGG |
|---|---|
| Data in this test | 2021-01-04 to 2026-10-02 (1444 sessions) |
| Total return, buy and hold | −4.5% |
| Annualized volatility | 5.8% |
| Deepest drawdown | −18.0% (2021-01-04 to 2022-10-20) |
| Up days | 49.3% |
| Average daily range | 0.35% |
| Average overnight gap | 0.21% |
| Correlation to SPY | 0.22 |
| Correlation to QQQ | 0.21 |
| Correlation to TLT | 0.92 |
| Sessions above the 200-day average | 63.6% |
| Crossings of the 200-day average | 50 |
| Falls of 10% or more from a 20-day high | 0 |
Why a bond fund suited a trend rule in this window
AGG fell for most of the test. Its total return was negative 4.53%, with annual returns of negative 1.64% in 2021, negative 13.02% in 2022, 5.62% in 2023, 1.35% in 2024, 7.19% in 2025 and negative 2.75% so far in 2026. The deepest drawdown ran from 2021-01-04 to 2022-10-20 with no recovery date by 2026-10-02.
A trend rule is built for this. It needs a persistent move in one direction, and 2022 gave one. AGG was above its 200-day average on 63.61% of sessions and crossed it 50 times, on a fund with annualized volatility of 5.82%. Many crossings mean lots of false signals, and the 22 trades with a 36% win rate reflect that.
The up-day share was 49.27%, with the average up day and down day both at 0.28%. Daily moves were small. The best day was 2.14% on 2022-11-10 and the worst was negative 1.63% on 2022-06-13. The fund's lag-1 autocorrelation was negative 0.01, which is close to nothing, so one day's move told you almost nothing about the next day's. Trend rules rely on persistence over weeks, not days, and the 2022 slide had it.
One more number shows how AGG made its return. The overnight log return was 6.82% and the intraday log return was negative 11.45%. The fund gained across the close and lost during the session. A rule that buys at the open and sells at the open holds the fund across overnight gaps, which averaged 0.21%, and is exposed to the intraday part when it is in.
AGG's correlation to TLT was 0.92, to SPY 0.22 and to QQQ 0.21. Its closest relatives were BND at 1.0, IEF at 0.97 and IGIB at 0.96. The same rule on the peers produced different outcomes. On SGOV it earned 3.21% with a 0.05% drawdown, on IGIB 2.35%, on BND 1.02% and on IEI 0.87%. IEF lost 0.39% and TLT lost 0.67%, with drawdowns of 10.63% and 15.92%. Among the Treasury funds, the longer-duration ones did worse here.
The rules
Hold while the 12-day exponential average is above the 26-day, the core of the MACD used as a position switch.
- WHEN the market opens · IF not invested AND EMA(12) > EMA(26) · THEN buy with 98% of the sleeve
- WHEN the market opens · IF invested AND EMA(12) < EMA(26) · THEN sell the whole position
The 12/26 exponential moving average pair is the core of the MACD indicator. Exponential averages weight recent days more than simple averages, so this crossover reacts faster than an SMA pair of the same length. Used as a long/flat switch, it gives you a position you can hold and measure.
Good for: traders who like MACD logic but want it expressed as a simple, testable long/flat rule.
Watch out: faster reaction means more trades and more whipsaws than a 50/200 cross; check the trade count on each backtest page.
What the rule does on a bond fund
The rule is a long or flat switch. When the market opens and the account holds nothing, it buys with 98% of the sleeve if the 12-day exponential average is above the 26-day. When the account holds the fund and the 12-day average is below the 26-day, it sells the whole position. There are no stops, no profit targets and no short positions.
An exponential average weights recent days more heavily than a simple average, so this pair turns sooner than a simple average pair of the same lengths. On a fund with a 5.82% annualized volatility and an average daily range of 0.35%, a short average pair can cross on very small moves. That shows up in the trade list: the shortest hold was 6 days and the median hold was 28 days. The average hold was 50 days, so a few long holds pulled the average up. The longest hold was 167 days.
The rule was in the fund at the close on 52.7% of trading days. On the remaining days the 12-day average sat below the 26-day and the account held cash. Cash earned nothing in this test, so the rule only gets paid for the days it is invested.
Other rules on the same fund
Among the other templates on AGG, the RSI(2) snapback led at 1.57% with a 10.61% drawdown, and the EMA rule came second at 1.07% with the shallowest drawdown of the group that traded. The SMA 10/50 trend made 0.79% with a 6.46% drawdown and the golden cross 0.78% with 7.13%. The 200-day regime filter made 0.31%. The dip buyer and the momentum breakout also show 0%. The dip buyer needs a 10% fall from a 20-day high, and AGG had none in the window.
Three templates lost money: RSI mean reversion at negative 0.23%, the weekly 7% target at negative 0.29% and the 3-month momentum rule at negative 0.74%. The monthly cycle lost 0.91% and the trend plus trailing stop lost 1.10%, with drawdowns of 18.88% and 18.83%. The four moving-average trend rules all finished positive.
What this test does not show
The test is one window of 5.7 years on one fund, with orders filled on minute bars, no margin and no fees in the headline run. Cash earned no interest. The rule's gain over buy-and-hold came from one year, 2022, in which AGG fell 12.7%. A window without a bond decline would have given the rule nothing to avoid, and the 2024 and 2025 results show it trailing a rising fund. Backtests are hypothetical. This page describes what happened in the data and makes no forecast.
Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.
Frequently asked questions
Did EMA 12/26 trend beat buy-and-hold on AGG?
Over 2021-01-04 to 2026-10-02, EMA 12/26 trend on AGG returned 1.1% annualized vs −0.8% for buy-and-hold: it beat buy-and-hold by 1.9% per year, with a maximum drawdown 12.7 points shallower than holding (4.9% vs 17.6%).
How many trades did it make?
22 completed round trips over 5.7 years (44 fills), with 36% of round trips closing profitably.
Is this the same as trading MACD signals?
It uses the MACD's underlying trend component. Classic MACD trades the signal-line crossover of the 12/26 spread. This template trades the spread's sign directly, which is simpler and can be built fully in blocks.
Did the EMA 12/26 trend rule beat buy-and-hold on AGG?
Yes in this window. The rule turned $10,000 into $10,632, a 1.07% CAGR, against $9,559 and negative 0.78% for buy-and-hold. It also had a 4.88% maximum drawdown against 17.57%. Most of the gap came from 2022, when the rule gained 0.6% and AGG lost 12.7%.
How many trades did the rule make on AGG?
It made 22 closed round trips and 44 fills over 5.7 years. Eight of them were winners, a 36% win rate. The average winner returned 2.08% and the average loser lost 0.72%.
Why was the rule out of the market in early 2022?
The 12-day average was below the 26-day, so the rule held cash from 2021-12-30 until it bought on 2022-07-13. Its position was flat for January through June 2022, which is why the monthly table shows zeros. AGG lost 12.7% over that calendar year.
What happens to the result with slippage?
At 5 basis points per fill the CAGR was 0.7% and the final value $10,411. At 10 basis points the CAGR was 0.32% and the final value $10,187. Both stayed above the buy-and-hold result of $9,559.
Does a different EMA pair change the answer?
Not by much. EMA 8/21 returned 0.78%, EMA 20/50 returned 0.86% and EMA 12/50 returned 1.15%, against 1.07% for 12/26. Trade counts ranged from 11 to 35.
How does this rule do on other bond funds?
It earned 3.21% on [SGOV](/learn/strategies/ema-12-26-trend/sgov/), 2.35% on [IGIB](/learn/strategies/ema-12-26-trend/igib/) and 1.02% on [BND](/learn/strategies/ema-12-26-trend/bnd/). It lost money on [IEF](/learn/strategies/ema-12-26-trend/ief/) and [TLT](/learn/strategies/ema-12-26-trend/tlt/), the longer-duration funds.
Related
Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.