IBD Relative Strength Rating (#PercentRank) and Mark Minervini Stage 2 Template in RealTest
Code an IBD-style 1 to 99 Relative Strength rating natively in RealTest using weighted quarterly ROC inside a standalone #PercentRank Data line (never #PctRank!), and combine it with all 8 Mark Minervini Stage 2 Trend Template rules for clean breakout and pullback systems.
- Critical RealTest 2.0 naming catch confirmed live is that RealTest's native cross-sectional percentile rank operator is #PercentRank (returning 0 to 100), NOT #PctRank or #Percent.
- Build an IBD-style weighted 12-month Relative Strength score cleanly in two standalone Data lines using rsRaw = IF(InSPX, 0.4 * ROC(C, 63) + 0.2 * ROC(C, 126) + 0.2 * ROC(C, 189) + 0.2 * ROC(C, 252), NaN) followed by rsRating = #PercentRank rsRaw.
- All 8 points of Mark Minervini's classic Stage 2 Trend Template (Price > MA150 & MA200, MA150 > MA200, MA200 rising 1 month, MA50 > MA150 & MA200, Price > MA50, >= 30 percent above 52-week low, within 25 percent of 52-week high, RS Rating >= 80) express cleanly in one readable RealTest Data block.
- Remember to mask rsRaw with IF(InSPX, ..., NaN) before calling #PercentRank so your 1 to 99 percentile ranks strictly active point-in-time index peers rather than unrelated ETFs or delisted symbols.
- Validated in RealTest 2.0 on survivorship-free S&P 500 stocks (2015 through 2024, $100,000 start), minervini_stage2_breakout reached $146,602 (-32.52 percent MaxDD across 718 breakout trades, catching leaders like CCL +15.97 percent at RS 97.78).
- Buying brief RSI(3) < 35 pullbacks inside the EXACT same Stage 2 Trend Template leaders (minervini_stage2_pullback, 4,305 trades) improved both ending equity ($151,498) AND slashed MaxDD by nearly 9 points down to -23.54 percent.
Translating Mark Minervini's 8-point Stage 2 Trend Template and Investor's Business Daily (IBD) 1-to-99 Relative Strength rating into clean RealTest code is one of the highest-intent searches among swing and momentum traders (with over 130 mentions on the RealTest user forum including How to Scan for Minervini's Trend Template & Investor Business Daily's Relative Strength). Almost every chatbot asked to write this script fails immediately by inventing #PctRank instead of RealTest's true native operator #PercentRank!
Every cross-sectional rank formula below follows the official RealTest #PercentRank documentation and was verified live in RealTest 2.0 on survivorship-free S&P 500 constituents (InSPX) from 2015 through 2024.
Exact IBD RS Rating (#PercentRank) and 8-Point Stage 2 Trend Template Mapping
RealTest computes a true point-in-time cross-sectional RS Rating across hundreds or thousands of stocks in milliseconds without external fundamental databases.
| Minervini / IBD Concept | Common Syntax Mistake | Validated RealTest 2.0 Syntax |
|---|---|---|
| Weighted 12-month IBD RS formula | Plain 252-day ROC (misses recent surge!) | 0.4 * ROC(C, 63) + 0.2 * ROC(C, 126) + 0.2 * ROC(C, 189) + 0.2 * ROC(C, 252) |
| Convert raw RS into 1 to 99 RS Rating |
#PctRank rsRaw (parse error!) |
rsRating: #PercentRank rsRaw (standalone Data line!) |
| Rising 200-day moving average (1 month) | Checking only ma200 > ma200[1]
|
ma200 > ma200[20] (sustained 1-month uptrend) |
| 52-week high & low proximity rules | Hardcoding static dollar ranges | C >= LLV(L, 252) * 1.30 and C >= HHV(H, 252) * 0.75 |
Always remember that #PercentRank must appear at the very start of its own dedicated Data item, and wrapping rsRaw inside IF(InSPX, ..., NaN) ensures every stock's 0-to-100 percentile is ranked strictly against active historical S&P 500 peers on that exact date (see our SetupScore and #Rank guide and our VCP contraction and native indicators guide).
Complete Validated RealTest Script (IBD RS #PercentRank + 8-Point Stage 2 Template)
Run this script in RealTest 2.0 to plot stacked MA50, MA150, and MA200 trend ribbons plus a live RS_Rating lower subpane while benchmarking Stage 2 breakouts against Stage 2 pullbacks.
Notes:
Mark Minervini 8-point Stage 2 Trend Template and IBD-style Relative Strength
percentile rating (1 to 99 via #PercentRank) coded natively in RealTest 2.0
on survivorship-free S&P 500 stocks (InSPX).
Settings:
DataFile: C:\RealTest\Data\SPY_Tickers.rtd
StartDate: 2015-01-01
EndDate: 2024-12-31
AccountSize: 100000
BarSize: Daily
Parameters:
numPos: 10
Data:
ma50: Avg(C, 50)
ma150: Avg(C, 150)
ma200: Avg(C, 200)
atr14: ATR(14)
lo52: LLV(L, 252)
hi52: HHV(H, 252)
// IBD-style weighted 12-month relative strength score (double weight on latest quarter)
rsRaw: IF(InSPX, 0.4 * ROC(C, 63) + 0.2 * ROC(C, 126) + 0.2 * ROC(C, 189) + 0.2 * ROC(C, 252), NaN)
rsRating: #PercentRank rsRaw
// Full 8-point Mark Minervini Stage 2 Trend Template
stage2: InSPX and C > 10 and Avg(C * V, 20) > 25000000
and C > ma150 and C > ma200
and ma150 > ma200
and ma200 > ma200[20]
and ma50 > ma150 and ma50 > ma200
and C > ma50
and C >= lo52 * 1.30
and C >= hi52 * 0.75
and rsRating >= 80
spyUp: Extern($SPY, C > Avg(C, 200))
Template: rs_base
Side: Long
Allocation: S.Equity
SetupScore: rsRating
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. Stage 2 Trend Template + 20-day breakout with 4x ATR trailing stop
Strategy: minervini_stage2_breakout
Using: rs_base
EntrySetup: spyUp and stage2 and C > HHV(C, 20)[1]
ExitStop: IF(BarsHeld >= 1, HHV(H - 4 * atr14, BarsHeld + 1), 0)
ExitRule: C < ma50
// 2. Stage 2 pullback: buys top RS leaders on brief RSI(3) pullback above MA50
Strategy: minervini_stage2_pullback
Using: rs_base
EntrySetup: spyUp and stage2 and RSI(3) < 35
ExitStop: IF(BarsHeld >= 1, FillPrice - 3 * atr14[BarsHeld], 0)
ExitRule: C > H[1] or BarsHeld >= 10
Charts:
MA50: ma50
MA150: ma150
MA200: ma200
RS_Rating: rsRating {|}
Validated 2015 to 2024 Stage 2 Breakout vs Stage 2 Pullback Results (InSPX)
Testing both entry styles strictly inside identical RS >= 80 Stage 2 leaders reveals why combining trend-template filtering with short-term pullback timing smooths equity dramatically.
| Stage 2 Execution Style (2015 to 2024, InSPX) | Completed Trades | Ending Equity ($100k start) | Max Drawdown | Behavior Profile |
|---|---|---|---|---|
minervini_stage2_pullback (Stage 2 + RSI(3) < 35) |
4,305 | $151,498 | -23.54% | Higher return & 9 pts shallower DD buying dips inside leaders |
minervini_stage2_breakout (Stage 2 + 20-Day High) |
718 | $146,602 | -32.52% | Longer multi-month trend rides (e.g., CCL +15.97% at RS 97.8) |

You can also convert this exact stage2 boolean straight into a daily end-of-day watchlist generator simply by adding a Scan section with Filter: stage2 and sorting descending by rsRating (covered in full in our RealTest daily scanner guide).
Scan and Trade Stage 2 Leaders with Production RealTest Tools
Want turnkey breakout flag scanners and validated momentum-rotation scripts ready to run in RealTest 2.0 today? Inspect our Breakout Flag Pattern Scanner, our RealTest Modern Breakout Strategy, and our RealTest NASDAQ Momentum Rotation Strategy.
Key terms
- #PercentRank Operator
- RealTest's native cross-sectional Data operator ranking each active symbol's value across the universe on a 0 to 100 percentile scale.
- IBD-Style Weighted RS
- A 12-month relative-strength formula weighting the latest quarter at 40 percent and each prior quarter at 20 percent before percentile ranking.
- Stage 2 Trend Template
- Mark Minervini's 8-rule moving average alignment, 52-week price proximity, and relative-strength checklist isolating institutional uptrends.
- Stage 2 Pullback Entry
- Entering top-ranked Stage 2 RS leaders on brief short-term oversold dips above MA50 rather than chasing extended 20-day highs.
- Cross-Sectional Percentile Masking
- Applying IF(InSPX, score, NaN) prior to #PercentRank so percentile ratings compare stocks strictly against valid historical index peers.
Frequently asked questions
What is the exact RealTest function for 1 to 99 IBD Relative Strength percentile ranking?
RealTest's built-in cross-sectional percentile function is #PercentRank (not #PctRank or #Percent). Compute your weighted 12-month ROC in one Data line (masked via IF(InSPX, ..., NaN)), then assign rsRating = #PercentRank rsRaw on the very next Data line.
How do you weight quarterly returns like IBD's Relative Strength formula in RealTest?
Give the most recent 63 trading days (quarter) double weight via 0.4 * ROC(C, 63) + 0.2 * ROC(C, 126) + 0.2 * ROC(C, 189) + 0.2 * ROC(C, 252). Passing that weighted score into #PercentRank produces a clean 0 to 100 daily RS Rating.
How do you code all 8 rules of Mark Minervini's Stage 2 Trend Template in RealTest?
Check C > ma150, C > ma200, ma150 > ma200, ma200 > ma200[20], ma50 > ma150 and ma50 > ma200, C > ma50, C >= LLV(L, 252) * 1.30, C >= HHV(H, 252) * 0.75, and rsRating >= 80 inside one Data expression.
Can I run the Minervini Stage 2 template as a daily RealTest watchlist scanner?
Yes. Add a Scan section with Filter set to stage2, output columns for C, rsRating, and distance to 52-week high, and run realtest.exe -scan after market close to export your ranked Stage 2 candidates to CSV.
Did Stage 2 breakouts or Stage 2 pullbacks have lower drawdown on S&P 500 stocks?
Across 2015 through 2024 on historical S&P 500 stocks, buying brief RSI(3) < 35 pullbacks inside Stage 2 leaders cut MaxDD from -32.52 percent down to -23.54 percent while finishing slightly higher ($151,498 vs $146,602).
Why should rsRaw return NaN when InSPX is false before calling #PercentRank?
Returning NaN for non-index stocks forces #PercentRank to compute percentiles strictly among active index constituents on that date, avoiding distortion from ETFs, indices, or out-of-universe tickers in the same .rtd file.