Sector and Industry Exposure Caps in RealTest Using InfoTRBC, MaxSameCat, and MaxCatExp
To cap sector concentration in RealTest, extract the 2-digit economic sector code via Top(InfoTRBC, 2) or Top(InfoGICS, 2), assign it to the strategy's Category directive, and enforce both MaxSameCat (max stocks per sector) and MaxCatExp (max percentage exposure per sector). Pair those caps with #ByEcon #Avg and #ByEcon #Rank inside Data to measure sector breadth and rank stocks strictly inside their own sector.
- Norgate Data stores 10-digit Refinitiv TRBC codes in InfoTRBC and 8-digit GICS codes in InfoGICS; calling Top(InfoTRBC, 2) cleanly extracts the top-level 2-digit economic sector.
- MaxSameCat and MaxCatExp silently do nothing unless you first declare Category inside the same Strategy (or Template) pointing to your numeric sector expression.
- Cross-sectional sector functions (#ByEcon #Avg for sector breadth and #ByEcon #Rank for intra-sector ranking) require wrapping non-qualifying tickers in IF(..., NaN) so excluded symbols do not distort sector averages.
- MaxSameCat limits the integer count of simultaneous positions per sector, whereas MaxCatExp limits total percentage allocation per sector (essential when volatility sizing produces unequal weights).
- Validated in RealTest 2.0 across survivorship-bias-free S&P 500 constituents (InSPX) from 2015 through 2024, uncapped 10-stock momentum ended at $207,005 (-44.98 percent max drawdown) while hard 2-stock / 25 percent TRBC sector caps ended at $156,793 (-49.63 percent max drawdown).
- Hard sector caps reduce single-sector crash risk (such as the 2000 tech bust or 2008 financials) but deliberately forfeit concentration upside during prolonged single-sector leadership eras like 2015 to 2024.
Unconstrained equity momentum systems naturally crowd into whichever sector is leading the market, routinely putting 60 to 80 percent of portfolio equity into Technology or Energy at the exact peak of a cycle. Across 37 dedicated threads (191 posts) on the RealTest user forum, traders repeatedly ask how to parse InfoTRBC or InfoGICS codes, wire up MaxSameCat and MaxCatExp without silent no-ops, and calculate sector-level breadth or intra-sector rankings.
Every category directive below aligns with the official RealTest Category documentation, and the full S&P 500 comparison was parsed and executed in RealTest 2.0 on historical InSPX constituents from 2015 through 2024.
How InfoTRBC, InfoGICS, and Category Directives Work Together
Norgate Data imports full hierarchical taxonomy numbers directly into RealTest symbol metadata. Instead of hardcoding fragile ticker lists by hand, use Top(code, digits) to slice any TRBC or GICS hierarchy to the exact granularity you want.
| Granularity Level | TRBC Formula (Norgate Default) | GICS Equivalent | Cross-Sectional Grouping Prefix |
|---|---|---|---|
| Economic Sector (broadest, ~10 sectors) | Top(InfoTRBC, 2) |
Top(InfoGICS, 2) |
#ByEcon / #ByGICS
|
| Business Sector / Industry Group | Top(InfoTRBC, 4) |
Top(InfoGICS, 4) |
#ByBus / #ByCat
|
| Industry Group / Sub-Industry | Top(InfoTRBC, 6) |
Top(InfoGICS, 6) |
#ByInd / #ByCat
|
| Activity / Full Code |
InfoTRBC (10 digits) |
InfoGICS (8 digits) |
#ByCat (uses strategy Category) |
The single most common mistake in RealTest sector scripts is setting MaxSameCat: 2 or MaxCatExp: 25 without also declaring Category: econSec inside the strategy block. Without Category defined, RealTest has no category key to group open positions by, so both caps pass silently with zero warning. Setting both MaxSameCat (position count) and MaxCatExp (percentage exposure) protects both equal-weight and volatility-sized portfolios cleanly.
Sector Breadth and Intra-Sector Ranking with #ByEcon
Beyond capping entries at the portfolio layer, RealTest lets you compute sector-internal breadth and relative rankings directly in Data using cross-sectional prefixes. Writing #ByEcon #Avg spxAbove calculates the exact percentage of S&P 500 stocks above their 200-day moving average inside each stock's own TRBC economic sector, while #ByEcon #Rank eligMom ranks every stock strictly against peers in the same sector.
Always filter out non-constituents with IF(InSPX, ..., NaN) before applying #ByEcon #Avg or #ByEcon #Rank. Returning 0 instead of NaN drags down sector breadth averages with thousands of inactive or out-of-index symbols. For general cross-sectional ranking mechanics, see our RealTest ranking and SetupScore guide and our RealTest market breadth and Extern() filter guide.
Complete Validated RealTest Script (Uncapped vs TRBC Sector-Capped Momentum)
The complete script below runs side-by-side S&P 500 monthly momentum rotation strategies in RealTest 2.0 across 2015 to 2024. Both strategies share identical universe liquidity filters, commissions, slippage, and secBreadth >= 0.50 sector-breadth confirmation via Template: sec_base, isolating the exact effect of Category, MaxSameCat, MaxCatExp, and intra-sector rank filtering.
Notes:
Sector and industry exposure caps in RealTest using InfoTRBC, Top(InfoTRBC, 2),
Category, MaxSameCat, MaxCatExp, and #ByEcon cross-sectional sector breadth
comparing uncapped vs sector-capped S&P 500 momentum rotation.
Settings:
DataFile: C:\RealTest\Data\SPY_Tickers.rtd
StartDate: 2015-01-01
EndDate: 2024-12-31
AccountSize: 100000
BarSize: Daily
Parameters:
numPos: 10
maxPerSec: 2
maxSecPct: 25
Data:
ma200: Avg(C, 200)
mom126: ROC(C, 126)
spyUp: Extern($SPY, C > Avg(C, 200))
liquid: C > 10 and Avg(C * V, 20) > 25000000
// Extract 2-digit TRBC economic sector code via Top(InfoTRBC, 2)
econSec: Top(InfoTRBC, 2)
// Sector-level breadth: percentage of S&P 500 stocks above 200-SMA inside each sector
spxAbove: IF(InSPX, C > ma200, NaN)
secBreadth: #ByEcon #Avg spxAbove
// Rank stocks strictly inside their own economic sector (#ByEcon #Rank)
eligMom: IF(InSPX and liquid and C > ma200, mom126, NaN)
secRank: #ByEcon #Rank eligMom
newMonth: Month <> Month[1]
baseEntry: newMonth and InSPX and liquid and spyUp and C > ma200 and secBreadth >= 0.50
Template: sec_base
Side: Long
SetupScore: mom126
Quantity: 100 / numPos
QtyType: Percent
MaxPositions: numPos
MaxExposure: 100
Commission: Max(1, Shares * 0.005)
OpenSlip: 0.0005 * FillPrice
ExitRule: newMonth and (not spyUp or C < ma200 or secRank > 15)
ExitTime: NextOpen
// 1. Uncapped sector risk: momentum can pile 6+ stocks into Technology simultaneously
Strategy: spx_uncapped_sectors
Using: sec_base
EntrySetup: baseEntry
// 2. Hard TRBC sector caps: max 2 stocks and max 25% exposure per economic sector
Strategy: spx_trbc_sector_capped
Using: sec_base
Category: econSec
MaxSameCat: maxPerSec
MaxCatExp: maxSecPct
EntrySetup: baseEntry and secRank <= 5
Charts:
MA200: ma200
Sector_Breadth: secBreadth {%|}
Validated 2015 to 2024 S&P 500 Results (The Real Trade-Off)
Running both strategies on historical S&P 500 data reveals an honest empirical lesson that textbook blog posts often gloss over.
| Strategy Variant (2015 to 2024, InSPX) | Completed Exits | Ending Equity ($100k start) | Max Drawdown | Max Exposure |
|---|---|---|---|---|
spx_uncapped_sectors (No Sector Cap) |
236 | $207,005 | -44.98% | 129.55% |
spx_trbc_sector_capped (Max 2 Stocks / 25% per TRBC Sector) |
226 | $156,793 | -49.63% | 123.73% |

Why did tightening sector caps lower returns and slightly increase drawdown across 2015 through 2024? Because that specific decade was dominated by mega-cap Technology leadership; forcing a 10-stock portfolio to cap Technology at 2 slots pushed 80 percent of capital into lower-momentum cyclical sectors that still sold off sharply during 2020 and 2022. Tight sector caps shine brightest during regime crashes centered in one overheated sector (like 2000 Tech or 2008 Financials) or inside multi-strategy portfolios where you cap correlated exposure across sleeves using RealTest's Combined block (covered in our RealTest multi-strategy combining guide).
Balancing Concentration Risk Across Multi-Strategy Portfolios
Rather than throttling your strongest single-strategy momentum leaders with arbitrary 2-stock limits, institutional traders frequently pair an equity momentum sleeve with uncorrelated mean-reversion, defensive bond/gold rotation, or short sleeves under portfolio-level exposure rules. To test clean starter scripts on your own machine, download templates from our free RealTest code library or grab the Free Mean-Reversion Strategy for RealTest and Python.
If you want complete open-source momentum rotation and diversified portfolio templates ready to run in RealTest 2.0, explore the RealTest NASDAQ Momentum Rotation Strategy, build custom multi-sleeve allocations interactively with our RealTest Strategy Combiner & Portfolio Builder, or inspect the complete RealTest Portfolios collection.
Key terms
- InfoTRBC
- A built-in RealTest symbol metadata variable storing Norgate Data's 10-digit Refinitiv Business Classification hierarchy, sliced into broad sectors via Top(InfoTRBC, 2).
- Category Directive
- A RealTest Strategy or Template setting that assigns a numeric grouping key (such as an economic sector code) to each symbol so MaxSameCat and MaxCatExp can enforce concentration limits.
- MaxSameCat
- A RealTest Strategy and Combined exposure limit capping the maximum number of simultaneous open positions allowed within any single Category value.
- MaxCatExp
- A RealTest Strategy and Combined risk constraint capping the maximum percentage of allocated capital permitted inside any single Category value.
- #ByEcon Cross-Sectional Prefix
- A RealTest Data-section modifier that restricts cross-sectional calculations (#Avg, #Rank, #Sum, #PercentRank) strictly to peer stocks sharing the same 2-digit TRBC economic sector.
Frequently asked questions
How do you extract the 2-digit sector code from InfoTRBC or InfoGICS in RealTest?
Use RealTest's built-in Top() function inside Data, such as econSec assigned to Top(InfoTRBC, 2) for Refinitiv TRBC economic sectors or Top(InfoGICS, 2) for GICS sectors. Use 4 digits for business sectors or industry groups and 6 digits for narrower industry classifications.
Why are MaxSameCat and MaxCatExp not limiting sector positions in my RealTest script?
Both MaxSameCat and MaxCatExp require the Category directive to be explicitly defined inside the Strategy or Template block (for example Category pointing to Top(InfoTRBC, 2)). Without Category set, RealTest cannot group holdings by sector and ignores both caps silently.
What is the difference between MaxSameCat and MaxCatExp in RealTest?
MaxSameCat enforces a maximum integer count of open positions sharing the same Category value (for example 2 stocks per TRBC sector). MaxCatExp enforces a maximum total exposure percentage allocated to any single category (for example 25 percent of strategy equity), which is essential when ATR or volatility sizing creates unequal position weights.
How do you calculate sector breadth or rank stocks inside their own sector in RealTest?
Combine a sector grouping prefix like #ByEcon with a cross-sectional aggregate such as #Avg or #Rank in the Data section. Always wrap the input expression in IF(InSPX, value, NaN) so inactive or out-of-universe symbols are excluded from the sector calculation.
Can RealTest apply MaxSameCat and MaxCatExp across multiple combined strategies?
Yes. RealTest supports MaxSameCat and MaxCatExp inside the Combined section when all member strategies share compatible Category values, preventing separate momentum and mean-reversion sleeves from piling into the same sector simultaneously.
Do hard TRBC sector caps always lower maximum drawdown?
No. In our 2015 to 2024 S&P 500 test, capping each TRBC economic sector at 2 stocks and 25 percent exposure lowered ending equity from $207,005 to $156,793 and did not beat uncapped drawdown (-49.63 percent vs -44.98 percent) because it rotated capital away from dominant Tech trends into cyclical sectors that still fell in broad market selloffs. Test sector cap thresholds across multiple market decades before locking them in.