Margin MaxInvested MinFreeCash RealTest RealTest Code Risk Management

Margin, IBKR Reg-T vs Portfolio Margin, MaxInvested, and MinFreeCash in RealTest

Summary

Model cash cushions, IBKR Reg-T overnight margin (150 percent), and Portfolio Margin (200 percent) realistically in RealTest using MaxInvested, Reduce, CashIntPct, and MarginIntPct, and keep MinFreeCash at the Combined account level because it evaluates shared account S.Cash.

· 5 min read
RealTest 2.0 margin modeling workbench showing MaxInvested and MarginIntPct script left, 85 percent vs 150 percent vs 200 percent equity curves top right, and results bottom right
Key findings
  • Realistic margin backtests in RealTest require setting both CashIntPct (interest earned on idle cash, e.g., 3.5 percent) and MarginIntPct (borrowing rate on debit balances, e.g., 6.5 percent) inside Settings so financing drag is never hidden.
  • MaxInvested enforces a dollar cap on open positions per strategy or StatsGroup (such as 0.85 * S.Equity for a 15 percent cash reserve, 1.5 * S.Equity for conservative Reg-T, or 2.0 * S.Equity for Portfolio Margin), while Reduce 1000 automatically shrinks the final order instead of skipping it.
  • Critical RealTest trap confirmed live is that MinFreeCash always checks Combined account S.Cash, NOT standalone sleeve cash, so placing MinFreeCash inside one sleeve while sibling strategies borrow margin blocks entries unexpectedly.
  • Validated in RealTest 2.0 on survivorship-free S&P 500 stocks (2015 through 2024, 6.5 percent MarginIntPct, 3.5 percent CashIntPct), mr_cash_85_reserve (MaxInvested 0.85 * S.Equity) grew $100,000 to $146,867 with only -16.55 percent MaxDD across 3,257 trades.
  • Scaling the identical mean-reversion system to IBKR Reg-T overnight borrowing (mr_regt_150_margin, MaxInvested 1.5 * S.Equity) raised ending equity to $197,438 across 3,513 trades while widening MaxDD to -26.39 percent.
  • Pushing to Portfolio Margin borrowing (mr_pm_200_margin, MaxInvested 2.0 * S.Equity) reached $234,125 across 3,513 trades, but expanded MaxDD to -34.37 percent and suffered heavier 6.5 percent margin interest drag during flat periods.

Modeling broker buying power accurately is one of the highest-impact topics on the RealTest user forum, with dozens of threads comparing Interactive Brokers Reg-T (2x overnight / 4x intraday) against Portfolio Margin, debugging MaxInvested versus MaxExposure, and troubleshooting why MinFreeCash unexpectedly skips trades. Ignoring MarginIntPct makes borrowed capital look free in backtests, while forgetting broker overnight caps invites forced liquidations in live crashes.

Every capacity and financing directive below matches the official RealTest MaxInvested and capacity constraints documentation and was validated live in RealTest 2.0 across ten years of survivorship-free S&P 500 stocks (2015 through 2024).

Exact RealTest Margin Directives and the MinFreeCash Multi-Strategy Trap

RealTest enforces account buying power through four clean capacity directives plus two interest-rate settings. Memorize the exact scope difference between MaxInvested and MinFreeCash before running multi-strategy tests.

Account / Broker Goal Common Mistake Validated RealTest 2.0 Syntax
Realistic cash yield & margin cost Leaving MarginIntPct at 0% (free borrowing!) CashIntPct: 3.5 and MarginIntPct: 6.5 in Settings
Per-sleeve 15% cash cushion Putting MinFreeCash inside one sleeve of a margin test MaxInvested: 0.85 * S.Equity + Reduce: 1000
Account-wide free cash floor Forgetting MinFreeCash reads Combined S.Cash Apply MinFreeCash: 0.15 * Combined(S.Equity) inside Combined
IBKR Reg-T vs Portfolio Margin cap Skipping the last order when slightly over cap MaxInvested: 1.5 * S.Equity (or 2.0 * S.Equity) + Reduce: 1000

Why did our own live RealTest validation flag MinFreeCash inside a multi-strategy comparison script? Because MinFreeCash checks shared account S.Cash across the entire test! When a cash sleeve runs inside the same script as sibling margin strategies that borrow cash, shared S.Cash turns negative and starves the cash sleeve of trades (dropping entries from 3,257 down to 431!). Use MaxInvested: 0.85 * S.Equity when capping cash reserve at the individual sleeve level, and reserve MinFreeCash strictly for account-wide cash protection inside the Combined section (see our RealTest ATR and volatility position sizing guide and our CashIntPct and MarginIntPct accounting guide).

Complete Validated RealTest Script (85% Cash Reserve vs 150% Reg-T vs 200% Portfolio Margin)

This RealTest 2.0 script runs identical survivorship-free S&P 500 mean-reversion entries under three progressively higher capital ceilings with 3.5 percent cash yield, 6.5 percent margin borrowing cost, and Reduce: 1000 partial order resizing.

Notes:
	Margin, IBKR Reg-T vs Portfolio Margin, MaxInvested, MinFreeCash, and
	MarginIntPct borrowing cost comparison in RealTest 2.0 on historical S&P 500 stocks.

Settings:
	DataFile:	C:\RealTest\Data\SPY_Tickers.rtd
	StartDate:	2015-01-01
	EndDate:	2024-12-31
	AccountSize:	100000
	BarSize:	Daily
	CashIntPct:	3.5
	MarginIntPct:	6.5

Data:
	ma200:	Avg(C, 200)
	rsi2:	RSI(2)
	atr14:	ATR(14)
	spyUp:	Extern($SPY, C > Avg(C, 200))
	liquid:	C > 10 and Avg(C * V, 20) > 25000000
	mrSig:	InSPX and liquid and spyUp and C > ma200 and rsi2 < 12

Template: margin_base
	Side:	Long
	Allocation:	S.Equity
	EntrySetup:	mrSig
	EntryLimit:	C - 0.35 * atr14
	EntryTime:	Intraday
	LimitExtra:	0.001 * C
	SetupScore:	100 - rsi2
	QtyType:	Percent
	Commission:	Max(1, Shares * 0.005)
	OpenSlip:	0.0005 * FillPrice
	ExitStop:	IF(BarsHeld >= 1, FillPrice - 3 * atr14[BarsHeld], 0)
	ExitRule:	C > H[1] or BarsHeld >= 7
	ExitTime:	NextOpen
	Ambiguity:	Stop

// 1. Cash account with 15% free cash cushion via MaxInvested (zero margin borrowing)
Strategy: mr_cash_85_reserve
	Using:	margin_base
	Quantity:	10
	MaxPositions:	10
	MaxExposure:	85
	MaxInvested:	0.85 * S.Equity
	Reduce:	1000

// 2. IBKR Reg-T 150% overnight margin cap (borrows excess at 6.5% MarginIntPct)
Strategy: mr_regt_150_margin
	Using:	margin_base
	Quantity:	15
	MaxPositions:	10
	MaxExposure:	150
	MaxInvested:	1.5 * S.Equity
	Reduce:	1000

// 3. Portfolio Margin 200% leverage cap showing return vs drawdown and interest drag
Strategy: mr_pm_200_margin
	Using:	margin_base
	Quantity:	20
	MaxPositions:	10
	MaxExposure:	200
	MaxInvested:	2.0 * S.Equity
	Reduce:	1000

Charts:
	MA200:	ma200

Validated 2015 to 2024 Margin Comparison (Including 6.5% MarginIntPct Drag)

Because every strategy uses Allocation: S.Equity, each curve compounds purely on its own equity and financing cost without cross-contamination. Notice that the blue Combined line in the chart sums all three test tiers simultaneously; evaluate the three individual curves for the apples-to-apples buying-power tradeoff.

Margin Tier (2015 to 2024, 6.5% Margin Cost) Completed Trades Ending Equity ($100k start) Max Drawdown Peak Exposure
mr_cash_85_reserve (85% Cap, 15% Cash Cushion) 3,257 $146,867 -16.55% 85.29%
mr_regt_150_margin (150% IBKR Reg-T Cap) 3,513 $197,438 -26.39% 152.16%
mr_pm_200_margin (200% Portfolio Margin Cap) 3,513 $234,125 -34.37% 207.14%
RealTest 2.0 log equity comparison of 100 percent cash account with MinFreeCash reserve, 150 percent IBKR Reg-T margin, and 200 percent Portfolio Margin leverage caps
RealTest 2.0 10-year comparison of 85% Cash Reserve ($146,867, -16.55% MaxDD), 150% Reg-T Margin ($197,438, -26.39% MaxDD), and 200% Portfolio Margin ($234,125, -34.37% MaxDD) after 6.5% margin borrowing costs.

Look at the nonlinear risk-reward tradeoff clearly visible in the table. Moving from 85 percent cash reserve to 150 percent Reg-T added $50,571 in profit while adding 9.84 points of drawdown. Pushing further from 150 percent to 200 percent Portfolio Margin added only $36,687 in incremental profit (as 6.5 percent margin interest ate harder into carry) while adding another 7.98 points of drawdown (-34.37 percent). That is why institutional multi-strategy accounts prefer combining uncorrelated low-exposure sleeves over cranking margin on a single equity strategy (see our StatsGroup allocation and correlation matrix guide).

Build Margin-Efficient Multi-Strategy RealTest Portfolios

Instead of stretching a single strategy to 200 percent margin and absorbing -34 percent drawdowns, combine uncorrelated strategies so idle cash from low-exposure mean reversion feeds trend and defensive sleeves safely inside Reg-T limits. Test how your own sleeves stack together in our RealTest Strategy Combiner & Portfolio Builder.

Ready for institutional-grade diversification with built-in risk ceilings? Inspect our All-Weather Low-Drawdown Portfolio, browse the complete RealTest Portfolios collection, or wire safe live margin caps directly into Interactive Brokers via our RealTest, OrderClerk, and IBKR Automation Course.

Key terms

MaxInvested
A RealTest capacity constraint capping total open invested dollars for a strategy, StatsGroup, or Combined portfolio via any dollar formula.
MinFreeCash
A RealTest account-level capacity constraint requiring Combined S.Cash after new entries to remain above a specified minimum dollar reserve.
MarginIntPct
A RealTest Settings directive charging annualized daily borrowing interest whenever open positions exceed available account cash.
Reduce Directive
A RealTest position-resizing setting (True or minimum dollar threshold like 1000) that trims an incoming order to fit remaining MaxInvested or MaxExposure capacity.
Reg-T Margin
Federal Reserve Regulation T brokerage margin standard limiting overnight equity exposure to 200 percent of account equity (50 percent initial requirement).

Frequently asked questions

What is the difference between MaxExposure and MaxInvested in RealTest?

MaxExposure is expressed as a percentage of Allocation (for example, MaxExposure 150 caps gross exposure at 150 percent of S.Alloc), whereas MaxInvested is expressed as an exact dollar formula (for example, MaxInvested 1.5 * S.Equity or a fixed dollar cap like 250000).

Why did MinFreeCash block trades when placed inside one strategy of a multi-strategy script?

MinFreeCash evaluates shared Combined account S.Cash rather than standalone sleeve cash. If sibling strategies in the same script borrow margin, Combined S.Cash drops below zero and triggers MinFreeCash skips. Use MaxInvested 0.85 * S.Equity for per-sleeve reserves and put MinFreeCash inside Combined.

How do you model Interactive Brokers margin interest accurately in RealTest?

Set MarginIntPct in Settings to your realistic broker debit rate (for example, MarginIntPct 6.5) and CashIntPct to your realistic idle-cash credit rate (for example, CashIntPct 3.5). RealTest accrues daily interest on debit and credit balances automatically.

What does Reduce 1000 do alongside MaxInvested?

When a new signal would push total open dollars slightly above MaxInvested, Reduce 1000 allows RealTest to shrink the new order down to the remaining available buying power as long as the resized trade is still at least $1,000, rather than skipping the trade completely.

How much overnight margin should you model for IBKR Reg-T vs Portfolio Margin?

IBKR Reg-T permits up to 200 percent overnight gross equity exposure (50 percent initial margin), though prudent live traders cap overnight MaxInvested around 130 to 160 percent to survive overnight gaps without margin calls. Portfolio Margin allows higher gross limits on diversified baskets, typically capped near 180 to 220 percent in conservative systems.

Why did 200 percent margin produce diminishing risk-adjusted gains compared to 150 percent?

With 6.5 percent annual MarginIntPct borrowing drag plus compounding volatility decay during drawdowns, moving from 150 percent to 200 percent added $36,687 in profit versus $50,571 from the first step while deepening MaxDD to -34.37 percent.

Related strategies

RealTest Strategy Combiner & Portfolio Builder
Combine multiple RealTest strategies interactively to optimize exposure, margin utilization, and drawdown caps.
View →
All-Weather Low-Drawdown Portfolio
Diversified multi-strategy RealTest portfolio engineered to deliver strong returns without fragile single-sleeve margin.
View →
Course on Connecting RealTest, OrderClerk, and IBKR
Learn exact IBKR margin safety buffers, OrderClerk order sequencing, and automated daily execution workflows.
View →
← Back to Learn

#1 RealTest Backtests

Supercharge Your Trading Now

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

Browse RealTest Strategies