Skip to main content

Faber 10-Month Timing — Pine Script v5 strategy

TRENDSMAPine Script v5

This script applies Mebane Faber's 2007 timing rule to a monthly chart. It holds a long position while the month closes above its 10-month simple moving average, and steps out when the month closes below it.

Full code (free to copy)

//@version=5
strategy("Faber 10-Month Timing", overlay=true, pyramiding=0, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1, process_orders_on_close=true, margin_long=0)
smaVal = ta.sma(close, 10)
if (close > smaVal)
    strategy.entry("Long", strategy.long)
if (close < smaVal)
    strategy.close("Long")

Results from July 2007, measured 31 October 2026

MarketLast dataTradesGainBuy & holdMax drawdownBuy & hold drawdownVerdict
S&P 500, dividends reinvested (Shiller) *2026-0610+589.95 %+595.97 %19.0 %49.0 %Inconclusive
US equities (Ken French)2026-0815+429.36 %+665.14 %18.75 %50.3 %Inconclusive
Developed ex-US (Ken French)2026-0819+106.70 %+170.29 %26.24 %55.9 %Inconclusive
Gold, monthly average price (World Bank) *2026-0914+529.41 %+548.18 %22.98 %39.3 %Inconclusive

Lab 0.1.0-253 judge, frozen rule with no tuning, 10 bps per fill. Rule chosen and frozen on 12 October 2026. The drawdown is descriptive: the judge does not count it in its verdict. Data: Robert J. Shiller; Kenneth R. French Data Library; World Bank Commodity Price Data (CC BY 4.0). Research on past data, not advice.

* Biased rows, corrected on 31 October 2026: the S&P 500 (Shiller) and gold (World Bank) series are monthly averages, so filling at that average happens partly before the signal is known. Gold recalculated with the fill one month later gives +322.5% against about +550%, with a 30.0% drawdown. That is a cautious case: the true figure lies between the two. The S&P 500 row was not recalculated and carries the same bias. Read the US and ex-US rows first: they use month-end returns. The code also ran on TradingView on 31 October 2026, with no compile error, on monthly bars. SP:SPX from 1871: +447,809% including the open position, against +155,216% for buy and hold, with a 37.8% drawdown and 103 closed trades. TVC:GOLD from 1832: +9,790% against +18,656%, with a 43.0% drawdown and 77 closed trades. Do not read these as the same test: most of that history predates the 2007 publication, SPX excludes dividends, which penalises buy and hold, and the October 2026 bar was not closed. The judged table above is our measure.

Read the full test of nine old rules →

How the script works

The header sets //@version=5 and calls strategy() with 100% of equity per entry, 0.1% commission per fill and process_orders_on_close=true, so orders fill at the close of the bar that gives the signal. smaVal is ta.sma(close, 10), a fixed length with no setting to tune.

When the close is above smaVal, strategy.entry("Long", strategy.long) opens the long position, or does nothing if it is already open. When the close is below smaVal, strategy.close("Long") closes it. The script never goes short and holds no position between an exit and the next entry.

The rule counts bars, not calendar months. It only means 10 months on a monthly chart: on a daily chart, the same code uses a 10-day average, which is a different strategy.

Parameters in the code

ParameterValueRole
ta.sma length10Length of the moving average, in chart bars. Use a monthly chart to get 10 months.
default_qty_value100Percent of equity invested on each entry.
commission_value0.1Commission per fill, in percent.
process_orders_on_closetrueFills orders at the close of the signal bar, not at the next open.

Known limits of this rule

Before you trust it: test it on data it never saw

A backtest in TradingView's Strategy Tester shows one past path with the settings you picked. Strategy Arena Lab (free, Windows and Linux) replays this Pine on your PC, compares its trades one by one with TradingView's for supported Pine, counts the variants you try, then judges the rule on a period kept sealed during the search: holds, mirage or inconclusive.

Get the free Lab →

FAQ

Does this rule beat buy and hold?

Not in our test from July 2007. On the two month-end series, US and ex-US equities, the gain stays well below buy and hold. The S&P 500 and gold rows look close, but monthly average prices bias them in the rule's favour. The maximum drawdown was smaller on all four, including gold with the delayed fill.

Which timeframe should I use?

A monthly chart. The code counts bars, so on another timeframe it no longer tests a 10-month average.

Can I run it in the online judge?

Not as a 10-month rule for now: the judge's data stops at daily bars, where this code would test a 10-day average. The free Strategy Arena Lab includes the monthly series used on this page.

Other free Pine Script v5 strategies

RSI Mean ReversionEMA Crossover 9/21EMA Ribbon 8/21/55Bollinger Band BounceMACD MomentumSuperTrendStochastic RSIATR BreakoutVWAP BounceRSI + EMA Combo
TradingView Starter
Choose the account path. Prove the strategy separately.
Your first chart and price alert do not require the Lab. Strategy Arena proof remains required before trusting or exporting a strategy.
Partner attribution is for first-time users and web purchases only. Strategy Arena may earn a commission on eligible purchases; starting with a free account needs no payment.
I have never had an account · Start free I already have an account Check a strategy
More TradingView paths
Evidence-gated Pine review

Educational code on past data. No investment advice; no result is promised.