Clenow Momentum MACD RealTest RealTest Code SuperTrend VCP

RealTest Indicators Code Cheat Sheet (SuperTrend, MACD, Clenow R-Squared, VCP, Squeeze)

Summary

RealTest 2.0 includes native one-pass indicators for SuperTrend(10, 3), MACD(12, 26), MACDS(12, 26, 9), MACDH(12, 26, 9), BBTop/BBBot, KBTop/KBBot, Slope, and Correl. Compute Clenow's annualized exponential regression score with (Exp(Slope(Log(C), 90)) ^ 252 - 1) * 100 * Correl(Log(C), BarNum, 90) ^ 2, code Minervini VCP contraction via ATR(5)/ATR(20), and build custom recursive indicators using self-referencing Data items like trend[1].

· 5 min read
RealTest 2.0 indicators workbench showing VNQ chart with SuperTrend, Bollinger Bands, and MACD_Hist top-left, 5-indicator script top-right, and Trade List bottom
Key findings
  • RealTest 2.0 ships with built-in SuperTrend(len, mult), MACD(12, 26), MACDS(12, 26, 9) signal line, MACDH(12, 26, 9) histogram, BBTop/BBBot, and KBTop/KBBot, eliminating verbose manual EMA loops.
  • For custom stateful indicators that are not built in, RealTest allows self-referencing Data formulas (such as referencing trend[1] inside trend with a BarNum <= len initialization check), replacing Pine Script or AFL loops natively.
  • Andreas Clenow's annualized exponential regression momentum score translates cleanly into RealTest using Log(C), Slope(logC, 90), Exp(regSlope) ^ 252 - 1, and Correl(logC, BarNum, 90) ^ 2 for R-Squared.
  • A Bollinger Band inside Keltner Channel volatility squeeze requires only four built-in lines (BBTop(20, 2) < KBTop(20, 1.5) and BBBot(20, 2) > KBBot(20, 1.5)).
  • Minervini Stage 2 Volatility Contraction (VCP) combines moving-average stacking (C > ma50 > ma150 > ma200) with short-to-long ATR contraction (ATR(5) / Max(ATR(20), 0.001) < 0.80).
  • Validated in RealTest 2.0 from 2010 through 2024 on diversified ETFs, our combined SuperTrend + MACD + Clenow R-Squared script executed 264 trend trades cleanly (1.23 profit factor, 4.14 percent average win vs 2.23 percent average loss, $123,397 ending equity).

Across 88 dedicated threads and more than 800 mentions on the RealTest user forum, indicator formulas are the single most common coding hurdle for traders migrating from TradingView Pine Script or AmiBroker. Ask a general LLM for Clenow's R-Squared momentum score, SuperTrend, or MACD signal crossovers in RealTest and it routinely invents Pine Script functions like ta.supertrend(), passes Close as an extra argument to MACD(C, 12, 26), or claims RealTest cannot compute recursive stateful indicators without loops.

Every indicator signature below comes straight from the official RealTest Indicator and Multi-Bar Function documentation, and all five indicator families were parsed, backtested, and plotted directly on real candlesticks in RealTest 2.0.

Quick Lookup Table of Verified RealTest 2.0 Built-In Indicators

Check exact argument counts before writing custom EMA loops. In RealTest, built-in price indicators operate implicitly on Close (or OHLC) and support fast one-pass calculation inside the Data section.

Indicator / Pattern Validated RealTest 2.0 Syntax Common AI Hallucination to Avoid
SuperTrend SuperTrend(10, 3) ta.supertrend(3, 10) or passing C as first argument
MACD Line MACD(12, 26) MACD(C, 12, 26) (fails with wrong number of arguments)
MACD Signal & Histogram MACDS(12, 26, 9) and MACDH(12, 26, 9) Signal(12, 26, 9) (does not exist in RealTest)
Clenow R-Squared Correl(Log(C), BarNum, 90) ^ 2 RSquared(C, 90) (does not exist; square Correl vs BarNum)
Clenow Annualized Slope (Exp(Slope(Log(C), 90)) ^ 252 - 1) * 100 LinRegSlope() (RealTest uses Slope(expr, count))
Bollinger & Keltner Bands BBTop(20, 2) / BBBot(20, 2) and KBTop(20, 1.5) / KBBot(20, 1.5) Passing C to BBTop (use BBTopF(expr, len, mult) for non-Close series)

Self-Referencing Recursive Indicators in RealTest (No Loops Required)

Although RealTest 2.0 now includes built-in SuperTrend(n, mult), knowing how RealTest's official self-referencing Data syntax works lets you code virtually any custom stateful indicator (such as custom trailing bands, adaptive filters, or custom SuperTrend variants) without procedural for loops. Simply initialize the first bars with IF(BarNum <= lenATR, ...) and reference the item's own prior bar via trend[1].

// Official self-referencing Data pattern for custom recursive SuperTrend
Data:
	nATR:	ATR(10)
	pAvg:	(H + L) / 2
	upperBand:	pAvg + 3 * nATR
	lowerBand:	pAvg - 3 * nATR
	// Positive value = uptrend support band; negative value = downtrend resistance band
	trend:	IF(BarNum <= 10, C,
		IF(trend[1] > 0,
			IF(C < trend[1], -upperBand, Max(trend[1], lowerBand)),
			IF(C > -trend[1], lowerBand, Max(trend[1], -upperBand))))
	customST:	Abs(trend)
	stDir:	Sign(trend)

Complete Validated RealTest Script (All 5 Indicator Families + Live Strategy)

Below is a complete, runnable script implementing all five forum-favorite indicator families side by side inside Data (SuperTrend, MACD/MACDS/MACDH, Clenow annSlope * rSquared, Bollinger/Keltner Squeeze, and Minervini Stage 2 VCP contraction), trading a clean SuperTrend + MACD + Clenow momentum trend rule and plotting four overlays directly on every Trade Chart.

Notes:
	Validated RealTest 2.0 indicator formulas for SuperTrend (built-in and
	custom self-referencing), MACD/MACDS/MACDH, Clenow annualized exponential
	slope x R-Squared, Minervini VCP contraction, and Bollinger/Keltner squeeze.

Settings:
	DataFile:	C:\RealTest\Data\MainETF.rtd
	StartDate:	2010-01-01
	EndDate:	2024-12-31
	AccountSize:	100000
	BarSize:	Daily

Parameters:
	numPos:	4
	stLen:	10
	stMult:	3
	regLen:	90

Data:
	isUniv:	Symbol = $SPY or Symbol = $VEU or Symbol = $GLD or Symbol = $TLT or Symbol = $VNQ or Symbol = $DBC or Symbol = $XLE or Symbol = $XLP or Symbol = $IYH or Symbol = $UUP
	atr14:	ATR(14)
	// 1. Built-in RealTest 2.0 SuperTrend (positive = uptrend, negative = downtrend)
	stLine:	SuperTrend(stLen, stMult)
	stUp:	C > stLine
	// 2. Built-in MACD, Signal Line (MACDS), and Histogram (MACDH)
	macdLine:	MACD(12, 26)
	macdSig:	MACDS(12, 26, 9)
	macdHist:	MACDH(12, 26, 9)
	macdBull:	macdLine > macdSig
	// 3. Clenow Annualized Log-Linear Regression Slope x R-Squared
	logC:	Log(C)
	regSlope:	Slope(logC, regLen)
	annSlope:	(Exp(regSlope) ^ 252 - 1) * 100
	rSquared:	Correl(logC, BarNum, regLen) ^ 2
	clenowScore:	annSlope * rSquared
	// 4. Bollinger Band inside Keltner Channel Volatility Squeeze
	bbUp:	BBTop(20, 2)
	bbDn:	BBBot(20, 2)
	kbUp:	KBTop(20, 1.5)
	kbDn:	KBBot(20, 1.5)
	inSqueeze:	bbUp < kbUp and bbDn > kbDn
	// 5. Minervini Volatility Contraction (VCP) Tightness Check
	ma50:	Avg(C, 50)
	ma150:	Avg(C, 150)
	ma200:	Avg(C, 200)
	vcpTight:	C > ma50 and ma50 > ma150 and ma150 > ma200 and ATR(5) / Max(ATR(20), 0.001) < 0.80

Strategy: supertrend_clenow_etf
	Side:	Long
	EntrySetup:	isUniv and stUp and macdBull and clenowScore > 10
	SetupScore:	clenowScore
	Quantity:	100 / numPos
	QtyType:	Percent
	MaxPositions:	numPos
	MaxExposure:	100
	Commission:	Max(1, Shares * 0.005)
	OpenSlip:	0.0005 * FillPrice
	StopSlip:	0.0005 * FillPrice
	ExitStop:	stLine
	ExitRule:	not stUp
	ExitTime:	NextOpen
	Ambiguity:	Stop

Charts:
	SuperTrend_Line:	stLine
	BB_Top:	bbUp
	BB_Bot:	bbDn
	MACD_Hist:	macdHist {|}

Validated in RealTest 2.0 from January 2010 through December 2024 on diversified ETFs, supertrend_clenow_etf executed 264 trend trades cleanly (every single position closed dynamically via the rising SuperTrend_Line ExitStop), achieving a 1.23 profit factor (4.14 percent average win versus 2.23 percent average loss, 35.58-bar average winning hold vs 12.07-bar losing hold, and $123,397 ending equity). Notice how cleanly ExitStop: stLine acts as a dynamic trailing stop directly from a Data indicator when no FillPrice is required (compare with split-safe Chandelier stops in our RealTest ExitStop and trailing stop guide and daily VCP scanning in our RealTest Scan and TestScan guide).

RealTest 2.0 multi-indicator candlestick chart on VNQ plotting SuperTrend line, Bollinger Bands, and MACD Histogram lower pane
RealTest 2.0 trade chart on VNQ (August 5 to October 3, 2024) plotting the blue SuperTrend_Line ratcheting underneath price, green BB_Top and red BB_Bot Bollinger Bands, and the blue MACD_Hist oscillator in the lower panel until ExitStop closes the trade cleanly at 95.42 (+7.48%).

More Ready-to-Use RealTest Indicators and Trend Strategies

Clean indicator building blocks save hours of debugging whenever you prototype new trend or rotation ideas in RealTest. To test more free code templates immediately, explore our free RealTest strategy and code library. We also publish dedicated, ready-to-import RealTest indicator modules including Aroon Indicator RealTest Code, RealTest Laguerre RSI Code, McGinley Dynamic RealTest Indicator, and Market Structure Indicator in RealTest.

If you want complete trend and momentum systems built with full transparent RealTest code rather than standalone indicators, review our RealTest Weekly Pullback Strategy, RealTest NASDAQ Momentum Rotation, and the RealTest Portfolios collection, or see our RealTest #Rank and momentum rotation guide.

Key terms

SuperTrend(len, mult)
A built-in RealTest 2.0 ATR-based trend and trailing-stop indicator that flips between support below price during uptrends and resistance above price during downtrends.
Clenow Momentum Score
Annualized exponential linear-regression slope multiplied by R-Squared (Correl(Log(C), BarNum, 90) ^ 2), favoring smooth consistent trends over erratic spikes.
MACDS and MACDH
RealTest's built-in three-argument functions returning the MACD EMA signal line (MACDS) and MACD histogram (MACDH) directly from Close.
Self-Referencing Data Item
A RealTest Data formula that reads its own prior-bar value (such as trend[1]) after a BarNum <= N initialization check, allowing stateful recursive indicators without loops.
BBTop / KBTop Squeeze
A volatility compression signal triggered when Bollinger Bands (BBTop/BBBot) contract inside Keltner Channels (KBTop/KBBot).

Frequently asked questions

Does RealTest have a built-in SuperTrend indicator?

Yes. RealTest 2.0 includes SuperTrend(len, mult) natively (such as SuperTrend(10, 3)). You can also build custom recursive SuperTrend variants inside the Data section by referencing the item's own prior bar (trend[1]) after initializing BarNum <= len.

How do you calculate Clenow annualized slope times R-Squared in RealTest?

Precompute logC as Log(C), regSlope as Slope(logC, 90), annSlope as (Exp(regSlope) ^ 252 - 1) * 100, and rSquared as Correl(logC, BarNum, 90) ^ 2 in Data, then multiply annSlope * rSquared to rank smooth exponential trends via SetupScore or #Rank.

What is the exact syntax for MACD and MACD signal line crossovers in RealTest?

Use MACD(12, 26) for the MACD line, MACDS(12, 26, 9) for the 9-period EMA signal line, and MACDH(12, 26, 9) for the histogram. Never pass Close as a first argument because RealTest's built-in MACD functions use Close automatically.

How do you code a Bollinger Band inside Keltner Channel squeeze in RealTest?

Compare built-in Bollinger and Keltner bands directly in Data via BBTop(20, 2) < KBTop(20, 1.5) and BBBot(20, 2) > KBBot(20, 1.5). Use BBTopF(expr, len, mult) whenever you need Bollinger Bands computed on a series other than Close.

How do you code Minervini Volatility Contraction Pattern (VCP) in RealTest?

Combine Stage 2 moving average alignment (C > Avg(C, 50) and Avg(C, 50) > Avg(C, 150) and Avg(C, 150) > Avg(C, 200)) with shrinking short-term volatility such as ATR(5) / Max(ATR(20), 0.001) < 0.80 and a tight 10-day high-low range.

How do you plot an oscillator like MACD Histogram in a separate lower chart pane in RealTest?

Append {|} to the item inside the Charts section (such as MACD_Hist as macdHist {|}). Items without {|} plot directly over the main candlestick price pane.

Related strategies

Aroon Indicator RealTest Code
Clean, ready-to-import RealTest indicator code for trend strength and breakout timing.
View →
RealTest Laguerre RSI Code
Smooth low-lag Laguerre RSI implementation in RealTest with transparent editable code.
View →
RealTest Weekly Pullback Strategy
Complete multi-timeframe trend and pullback RealTest strategy engineered beyond standalone indicator signals.
View →
← Back to Learn

#1 RealTest Backtests

Supercharge Your Trading Now

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

Browse RealTest Strategies