Trend following bot: Faber’s 10-month moving average
A trend following bot holds an asset while its price trend is up and steps aside when it turns down. This template runs Mebane Faber’s 10-month moving average rule on the S&P 500: hold SPY above the average, hold Treasury bills below it. You can read every rule, check the backtest, and run it on paper or in your own Alpaca account.
Key points#
- The bot checks once a month and holds either SPY or BIL, a Treasury bill fund.
- It holds stocks while the S&P 500 is above its 10-month moving average.
- In the backtest it cut the S&P 500’s worst drawdown by more than half.
- It finished 2008 slightly positive, but lost to the market in choppy years like 2010.
- You run your own copy, and you choose the balance it trades.
What does the trend following bot do?#
The bot follows one rule from Faber’s 2007 paper, “A Quantitative Approach to Tactical Asset Allocation”. A moving average is the average price over a set time. Here it is the average of the last ten month-end closes.
At the close of the last trading day of each month:
- If SPY is above its 10-month moving average, hold SPY.
- If it is below, hold BIL.
The rule does not try to predict anything. It accepts that it will sell late and buy back late. The goal is to miss the middle of a long decline. The full rules, sources and yearly results are in Faber’s 10-month moving average timing model.
How did trend following do in the backtest?#
These figures come from the strategy’s article and were measured on prices through September 25, 2026.
- Over the ETF era it compounded at about 8% a year, the same as a 60/40 portfolio.
- It cut the S&P 500’s worst drawdown by more than half. A drawdown is how far a portfolio falls from its last high point.
- It finished 2008 slightly positive after leaving stocks early in the year, while the S&P 500 lost more than a third.
- In 2010 it lost about 2% while the S&P 500 gained 15%, because prices kept crossing the average.
- It also fell far behind in 2019 and 2023, when it sold into a decline and bought back after much of the rebound.
These are hypothetical backtests on past prices after trading costs, not a track record. Why past results mislead explains the traps.
How to run the trend following bot on Tactfolio#
Five steps take you from the rule to a running bot.
- Open the live strategy. Open the live trend following strategy to see its rule and its daily-updated backtest.
- Copy it to your account. Sign up for free and copy it. Your copy is yours to change.
- Change it if you want. In the builder, try a different average length or a different market. The backtest reruns as you edit.
- Run it on paper. In Trade, a paper account runs the bot with pretend money at real market prices and emails you a summary after each close.
- Connect Alpaca when you are ready. Use your own Alpaca account, paper or live, with your own API keys. The bot trades only the starting balance you give it.
When does the trend following bot struggle?#
- Fast crashes and rebounds. A monthly check on a slow average reacts too late to a crash that reverses within weeks.
- Sideways markets. Prices crossing back and forth around the average cause repeated small losses, called whipsaws.
Common questions#
What is a trend following bot?#
It is a bot that holds an asset while its trend is up and moves to cash when the trend turns down. This one uses a 10-month moving average on the S&P 500.
Is the 10-month moving average the same as the 200-day?#
Not quite. Faber’s average uses one price per month, while the 200-day moving average uses 200 daily closes. They look back over a similar stretch, but the 10-month version changes only at month end.
How often does the trend following bot trade?#
It checks once a month and trades only when the price has crossed the average since the last check. In a steady trend it can hold the same fund for years.
Can I use trend following on other funds?#
Yes. Copy the strategy and swap SPY for another fund. Faber also applied the same rule to five asset classes in his Global Tactical Asset Allocation portfolio.
Sources
- A Quantitative Approach to Tactical Asset Allocation (2007, updated 2013), Mebane Faber, SSRN, accessed October 16, 2026
- Paper Trading, Alpaca, accessed October 16, 2026