Clenow Multi-Timeframe RealTest RealTest Code Trend Following Weekly

Weekly Trend Following in RealTest (BarSize Weekly, Clenow Momentum, and Pullbacks)

Summary

Setting BarSize Weekly in RealTest automatically builds weekly OHLCV bars from your daily .rtd file so every indicator runs in weekly units (40-week SMA, 18-week Clenow Slope x R-Squared annualized via ^ 52). To check a daily index filter inside a weekly script without look-ahead bias, nest Extern($SPY, Extern(~Daily, C > Avg(C, 200))) directly inside Data.

· 5 min read
RealTest 2.0 weekly trend following workbench displaying AAPL chart with stepped 40-week moving average left and complete BarSize Weekly Clenow script right
Key findings
  • BarSize Weekly compresses daily Norgate .rtd bars into weekly candles automatically, so 40-week moving averages replace 200-day SMAs and Clenow exponential regression slopes annualize using Exp(wSlope) ^ 52 - 1 instead of ^ 252.
  • RealTest supports true multi-timeframe regime checks inside weekly scripts via nested Extern($SPY, Extern(~Daily, C > Avg(C, 200))), eliminating manual Friday-bar hacks or separate daily data imports.
  • Because weekly ExitStop orders test against the full 5-day high-low range of each weekly bar, always set Ambiguity Stop and explicit StopSlip (such as 0.001 * FillPrice) for realistic fills.
  • Validated in RealTest 2.0 on survivorship-bias-free S&P 500 stocks (InSPX) across 521 weekly bars from 2015 through 2024, Clenow weekly momentum trend following ended at $197,733 (-28.28 percent MaxDD across just 247 completed exits).
  • By contrast, an unfiltered weekly RSI(2) pullback strategy over the exact same weekly bars ended at $110,217 (-43.66 percent MaxDD across 1,408 exits), showing that weekly pullbacks need tighter volatility or daily-bar exit precision.
  • RealTest charts weekly indicators cleanly as a stepped staircase line over daily candlesticks (visible on the AAPL trade chart), making visual stop and trend verification effortless.

Weekly trend following systems popularized by Andreas Clenow and Nick Radge remain favorites among part-time systematic traders who want to review orders once a weekend rather than every afternoon. Across 55 forum topics (469 posts), RealTest users repeatedly ask how BarSize: Weekly handles daily data files, how to annualize weekly exponential regression slopes properly, and how to combine a daily SPY 200-day regime filter inside a weekly script without introducing look-ahead bias.

Every multi-timeframe directive below follows the official RealTest BarSize documentation, and the dual weekly script was validated directly in RealTest 2.0 across 521 weekly bars (2015 through 2024) on historical InSPX S&P 500 constituents.

Key Adjustments When Switching to BarSize Weekly in RealTest

You never need to download separate weekly CSV or Norgate files for RealTest. Setting BarSize: Weekly inside Settings tells RealTest to aggregate your existing daily .rtd file into clean weekly OHLCV bars automatically. However, three formula adjustments are mandatory so your math stays consistent with weekly time units.

Component Daily BarSize Script Weekly BarSize Script (BarSize: Weekly)
Long-term trend filter Avg(C, 200) Avg(C, 40) (40 weeks equals ~200 trading days)
Clenow annualized log slope (Exp(Slope(Log(C), 90)) ^ 252 - 1) * 100 (Exp(Slope(Log(C), 18)) ^ 52 - 1) * 100 (18 weeks, ^ 52 annualization)
Daily SPY 200-day regime check Extern($SPY, C > Avg(C, 200)) Extern($SPY, Extern(~Daily, C > Avg(C, 200)))
Trailing Chandelier ATR stop HHV(H - 3 * ATR(14), BarsHeld + 1) HHV(H - 3 * ATR(10), BarsHeld + 1) with Ambiguity: Stop

The nested Extern($SPY, Extern(~Daily, C > Avg(C, 200))) pattern is one of RealTest's cleanest multi-timeframe features. Using ~Daily evaluates SPY's exact 200-day moving average on the daily series as of each week's closing date, preventing any future-week peeking while letting your portfolio trade strictly on Monday's open (ExitTime: NextOpen). For full daily Clenow regression and indicator syntax, see our RealTest SuperTrend, MACD, VCP, and Clenow R-Squared guide and our RealTest trailing stop ExitStop guide.

Complete Validated RealTest Script (Weekly Clenow Trend vs Weekly Pullback)

The complete script below compares two classic weekly equity styles head-to-head on identical S&P 500 liquidity, commissions, slippage, and daily SPY regime filters via Template: wk_base. Strategy 1 ranks stocks by Clenow's weekly annSlope * wR2 smoothness score and trails a 3x 10-week ATR Chandelier stop; Strategy 2 buys weekly RSI(2) < 30 pullbacks above the 40-week moving average.

Notes:
	Weekly multi-timeframe trend following in RealTest (BarSize Weekly)
	comparing Clenow weekly exponential regression momentum against
	weekly trend pullbacks with a nested Daily SPY 200-day regime filter.

Settings:
	DataFile:	C:\RealTest\Data\SPY_Tickers.rtd
	StartDate:	2015-01-01
	EndDate:	2024-12-31
	AccountSize:	100000
	BarSize:	Weekly

Parameters:
	numPos:	10
	regWeeks:	18

Data:
	// Weekly bar indicators (40 weeks ~= 200 trading days)
	ma40w:	Avg(C, 40)
	atr10w:	ATR(10)
	rsi2w:	RSI(2)
	// Nested Daily SPY 200-day regime check inside a Weekly BarSize script
	spyDailyUp:	Extern($SPY, Extern(~Daily, C > Avg(C, 200)))
	liquid:	C > 15 and Avg(C * V, 10) > 100000000
	// Clenow Weekly Exponential Regression Slope x R-Squared (18 weeks ~= 90 days)
	logC:	Log(C)
	wSlope:	Slope(logC, regWeeks)
	annSlope:	(Exp(wSlope) ^ 52 - 1) * 100
	wR2:	Correl(logC, BarNum, regWeeks) ^ 2
	clenowRank:	annSlope * wR2

Template: wk_base
	Side:	Long
	QtyType:	Percent
	Quantity:	100 / numPos
	MaxPositions:	numPos
	MaxExposure:	100
	Commission:	Max(1, Shares * 0.005)
	OpenSlip:	0.0005 * FillPrice
	StopSlip:	0.001 * FillPrice
	ExitTime:	NextOpen
	Ambiguity:	Stop

// 1. Weekly Clenow Momentum Trend Follower with Weekly Chandelier Trailing Stop
Strategy: spx_weekly_clenow
	Using:	wk_base
	EntrySetup:	InSPX and liquid and spyDailyUp and C > ma40w and clenowRank > 25
	SetupScore:	clenowRank
	ExitStop:	IF(BarsHeld >= 1, HHV(H - 3 * atr10w, BarsHeld + 1), 0)
	ExitRule:	C < ma40w

// 2. Weekly Pullback in Uptrend (buys weekly oversold dips above 40-week MA)
Strategy: spx_weekly_pullback
	Using:	wk_base
	EntrySetup:	InSPX and liquid and spyDailyUp and C > ma40w and C < C[1] and rsi2w < 30
	SetupScore:	100 - rsi2w
	ExitStop:	IF(BarsHeld >= 1, FillPrice - 2.5 * atr10w[BarsHeld], 0)
	ExitRule:	C > H[1] or BarsHeld >= 4

Charts:
	MA40_Weekly:	ma40w

Validated 2015 to 2024 Weekly Bar Results (Trend vs Pullback)

Testing both weekly strategies across 10 years of S&P 500 trading reveals a sharp structural difference between weekly momentum trend following and naive weekly mean-reversion dips.

Weekly Strategy (2015 to 2024, 521 Weeks) Completed Exits Ending Equity ($100k start) Max Drawdown Primary Exit Driver
spx_weekly_clenow (Weekly Clenow + Chandelier Stop) 247 $197,733 -28.28% 203 ExitStop, 33 ExitRule
spx_weekly_pullback (Weekly RSI(2) Pullback) 1,408 $110,217 -43.66% 1,309 ExitRule, 98 ExitStop
RealTest 2.0 weekly bar size equity and drawdown comparison between Clenow exponential regression trend following and weekly pullback strategies on S&P 500 stocks
RealTest 2.0 Daily Stats Graph plotting spx_weekly_clenow (green) against spx_weekly_pullback (maroon) across 2015 through 2024. Weekly Clenow momentum captured multi-month leaders (such as AAPL +17.96% in H2 2024) with low turnover and -28.28% drawdown, while raw weekly dips suffered deeper -43.66% drawdowns.

Notice why raw weekly pullback entries lagged on weekly bars. On BarSize: Weekly, a stock can drop five straight sessions inside one bar before your next weekly close exit triggers, whereas a proper weekly pullback system uses disciplined limit entries, multi-timeframe volatility filters, or daily-bar stop execution. Similarly, weekly trend followers thrive on letting big trends breathe with low turnover (247 exits in 10 years equals roughly 25 trades per year). Compare this with daily breakout pyramiding in our RealTest Donchian Turtle breakout guide.

Production-Grade Weekly and Momentum Systems for RealTest

If you like weekend-only execution and want clean starter code to explore locally, visit our free RealTest code library or grab the Free Mean-Reversion Strategy for RealTest and Python.

For complete, battle-tested weekly and momentum systems with full editable RealTest source code, inspect our RealTest Weekly Pullback Strategy (engineered specifically to avoid the naive weekly drawdown trap shown above), our RealTest NASDAQ Momentum Rotation Strategy, our Turtle Max Growth Strategy, or the full RealTest Portfolios collection.

Key terms

BarSize Weekly
A RealTest Settings directive that aggregates daily price data into weekly OHLCV bars automatically so all Data formulas, entries, and exits run on weekly cadence.
Extern(~Daily, ...)
RealTest's multi-timeframe reference syntax allowing a Weekly or Monthly script to evaluate exact Daily indicators (such as a 200-day SMA on SPY) without look-ahead bias.
Clenow Weekly Score
An annualized weekly exponential regression growth rate ((Exp(Slope(Log(C), 18)) ^ 52 - 1) * 100) multiplied by its R-squared goodness of fit to rank smooth, persistent uptrends.
Weekly Chandelier Stop
A volatility trailing exit coded as HHV(H - 3 * ATR(10), BarsHeld + 1) on weekly bars that ratchets upward behind winning trends while filtering out routine daily noise.
Ambiguity Stop
A RealTest Strategy fill-priority rule ensuring that whenever both an intraday stop and a target could trigger inside the same weekly bar, the loss-limiting stop fills first.

Frequently asked questions

Do I need a separate weekly data file to use BarSize Weekly in RealTest?

No. RealTest automatically builds weekly OHLCV bars on the fly from your standard daily .rtd file whenever you put BarSize Weekly in Settings, and recalculates all Data indicators strictly in weekly bar units.

How do you reference a Daily 200-day moving average inside a BarSize Weekly RealTest script?

Use nested Extern syntax with the ~Daily timeframe keyword inside Data, writing Extern($SPY, Extern(~Daily, C > Avg(C, 200))). RealTest evaluates the daily indicator as of the end of each week cleanly without look-ahead bias.

How should Clenow's exponential regression slope be annualized on Weekly bars in RealTest?

Compute wSlope as Slope(Log(C), 18) for an 18-week window (roughly 90 trading days), then annualize using (Exp(wSlope) ^ 52 - 1) * 100 instead of raising to the 252nd power. Multiply by Correl(Log(C), BarNum, 18) ^ 2 to weight smooth trends ahead of jagged spikes.

Why does a weekly moving average look like a staircase on a RealTest trade chart?

RealTest displays individual trade charts on daily candlesticks by default while keeping weekly Data indicators constant across all five daily bars of each week. That stepped visual makes it easy to inspect exact weekly trend thresholds against daily price action.

Why is Ambiguity Stop critical in BarSize Weekly RealTest backtests?

A single weekly bar spans five trading sessions, so price can frequently touch both a stop level and a limit or reversal level inside the same bar. Setting Ambiguity Stop plus explicit StopSlip enforces conservative pessimistic fill assumptions.

How many trades per year does a 10-position weekly Clenow trend follower generate?

In our 2015 to 2024 S&P 500 RealTest validation, spx_weekly_clenow executed 247 completed exits across 10 years, averaging about 25 round-trip trades per year for very low commission drag and minimal weekend maintenance.

Related strategies

RealTest Weekly Pullback Strategy
Low-maintenance weekly equity pullback RealTest strategy engineered with disciplined filters and full open source code.
View →
RealTest NASDAQ Momentum Rotation
Systematic momentum rotation RealTest script capturing high-conviction growth leaders with strict trend and risk rules.
View →
Turtle Max Growth Strategy
Classic trend-following breakout and volatility-trailing RealTest system modernized for multi-decade equity compounding.
View →
← Back to Learn

#1 RealTest Backtests

Supercharge Your Trading Now

Reduce drawdown, build diversification, or speed up your development time.

Browse RealTest Strategies