Hedging Long Short MaxNetExp MinNetExp RealTest RealTest Code

Long-Short Equity Portfolios and Net Exposure Caps (MaxNetExp & MinNetExp) in RealTest

Summary

Build unified Long-Short equity portfolios in RealTest by combining Side Long and Side Short strategies over one cash pool, enforcing net beta boundaries cleanly inside Combined via MaxNetExp and MinNetExp, and deducting realistic short borrow costs via FeesInOut.

· 5 min read
RealTest 2.0 Long-Short portfolio workbench showing Combined MaxNetExp and MinNetExp script left, Long vs Short vs Combined equity top right, and trade list bottom right
Key findings
  • RealTest controls portfolio-level market direction cleanly inside Combined via MaxNetExp (maximum net Long minus Short exposure percentage) and MinNetExp (minimum net exposure floor, such as -40 percent).
  • Always deduct annualized short-stock borrow costs inside Side Short strategies using FeesInOut -(S.Invested * 0.015 / 252) plus wider OpenSlip and StopSlip to reflect short-selling friction honestly.
  • When Side Short exits with a stop loss, remember the sign flips compared to longs (ExitStop FillPrice + 3 * atr14[BarsHeld] above entry price, and ExitRule C < L[1] on downward mean reversion).
  • Validated in RealTest 2.0 on survivorship-free S&P 500 stocks (2015 through 2024, $100,000 start, 3.5 percent CashIntPct), ls_long_mr (4,289 trades) reached $194,929 (-20.04 percent MaxDD) while standalone ls_short_fade (1,094 trades) ended at $82,154 (-17.11 percent MaxDD) across a roaring decade-long equity bull market.
  • Critically, inspect the daily equity curve during the 2020 COVID crash and 2022 bear market. The short fade sleeve spiked sharply positive right when equities dropped, helping Combined finish at $196,018 (0.59 Sharpe, 74.93 percent AvgExp) while enforcing the [-40 percent, +60 percent] net exposure corridor.
  • Short sleeves inside a secular bull market act as crisis insurance and correlation dampeners rather than standalone profit engines, demanding tighter parabolic overextension criteria (such as Qullamaggie-style blowoff fades) to earn positive standalone alpha.

Building unified Long-Short equity portfolios, capping net directional beta exposure, and auditing whether a short-side sleeve truly helps or hurts a long portfolio across real bear markets show up across nearly 100 topic discussions on the RealTest user forum. Most backtesting platforms force you to run Long and Short scripts separately and merge spreadsheets afterwards, completely missing shared margin, net-exposure caps, and real-time cash interest. RealTest models Long and Short sleeves inside one single Top-Down engine natively.

Every net-exposure and short-selling directive below matches the official RealTest MaxNetExp and MinNetExp documentation and was validated live in RealTest 2.0 on survivorship-free S&P 500 stocks (InSPX) from 2015 through 2024.

Exact Long-Short Architecture and Combined Net Exposure Corridor Rules

Keep these four rules right at the front of your mind whenever mixing Side: Long and Side: Short strategies inside one RealTest portfolio.

Long-Short Portfolio Mechanic Common Mistake Validated RealTest 2.0 Syntax
Cap net directional exposure (Long - Short) Using only gross MaxExposure (ignores offset!) Combined: with MaxNetExp: 60 and MinNetExp: -40
Short catastrophe stop direction Copy-pasting FillPrice - 3 * atr14 (below entry!) ExitStop: IF(BarsHeld >= 1, FillPrice + 3 * atr14[BarsHeld], 0)
Annual short stock borrow cost Assuming 0% borrow fee on short positions FeesInOut: -(S.Invested * 0.015 / 252) (1.5% large-cap / higher on small caps)
Higher short-side execution friction Copying long-only slippage onto short squeezes Use wider OpenSlip: 0.0008 * FillPrice and StopSlip: 0.0015 * FillPrice

Notice how Combined: MaxNetExp: 60 and MinNetExp: -40 work in RealTest's Top-Down selection loop. Because net exposure equals S.LongExp - S.ShortExp, opening 20 percent in short hedges automatically opens 20 percent of net long headroom while keeping gross account gearing bounded! For dedicated deep-dive syntax on shorting volatile parabolic blowoffs, read our RealTest parabolic short-selling guide and our StatsGroup and correlation matrix guide.

Complete Validated RealTest Script (Long MR + Short Fade + Combined MaxNetExp Corridor)

Run this unified Long-Short script in RealTest 2.0 to inspect both sleeves alongside the net-capped Combined equity curve across 2015 through 2024.

Notes:
	Long/Short hedged equity portfolio in RealTest 2.0 combining a Long Mean Reversion
	sleeve with a Short Overextended sleeve governed by Combined MaxNetExp and MinNetExp
	capacity caps plus realistic short borrow fees via FeesInOut.

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

Data:
	ma200:	Avg(C, 200)
	rsi2:	RSI(2)
	rsi3:	RSI(3)
	roc5:	ROC(C, 5)
	atr14:	ATR(14)
	liquid:	C > 15 and Avg(C * V, 20) > 30000000

// 1. Long sleeve: buys oversold S&P 500 pullbacks above MA200
Strategy: ls_long_mr
	Side:	Long
	EntrySetup:	InSPX and liquid and C > ma200 and rsi2 < 10
	SetupScore:	100 - rsi2
	QtyType:	Percent
	Quantity:	10
	MaxPositions:	8
	MaxExposure:	80
	Commission:	Max(1, Shares * 0.005)
	OpenSlip:	0.0005 * FillPrice
	StopSlip:	0.001 * FillPrice
	ExitStop:	IF(BarsHeld >= 1, FillPrice - 3 * atr14[BarsHeld], 0)
	ExitRule:	C > H[1] or BarsHeld >= 7
	ExitTime:	NextOpen
	Ambiguity:	Stop

// 2. Short hedge sleeve: fades parabolic 5-day surges in downtrending stocks (< MA200)
Strategy: ls_short_fade
	Side:	Short
	EntrySetup:	InSPX and liquid and C < ma200 and rsi3 > 90 and roc5 > 8
	SetupScore:	roc5
	QtyType:	Percent
	Quantity:	10
	MaxPositions:	6
	MaxExposure:	60
	FeesInOut:	-(S.Invested * 0.015 / 252)
	Commission:	Max(1, Shares * 0.005)
	OpenSlip:	0.0008 * FillPrice
	StopSlip:	0.0015 * FillPrice
	ExitStop:	IF(BarsHeld >= 1, FillPrice + 3 * atr14[BarsHeld], 0)
	ExitRule:	C < L[1] or BarsHeld >= 6
	ExitTime:	NextOpen
	Ambiguity:	Stop

// Enforce combined net long/short exposure corridor [-40%, +60%]
Combined:
	MaxNetExp:	60
	MinNetExp:	-40

Charts:
	MA200:	ma200

Validated 2015 to 2024 Long-Short Portfolio Results (InSPX)

Evaluating a generic S&P 500 short fade honestly over a massive 10-year bull market illustrates both the mechanics of MaxNetExp and why short-side selection must be far more selective than simple RSI overbought fades.

Portfolio Component (2015 to 2024, InSPX) Completed Trades Ending Equity ($100k start) Max Drawdown Peak Exposure
ls_long_mr (Long Oversold Mean Reversion) 4,289 $194,929 -20.04% 82.30%
ls_short_fade (Short 5-Day Surge Below MA200 + 1.5% Borrow) 1,094 $82,154 -17.11% 63.86%
Combined (MaxNetExp: 60, MinNetExp: -40, 0.59 Sharpe) 5,383 $196,018 -26.23% 142.45%
RealTest 2.0 Long/Short hedged portfolio equity graph combining Long mean reversion, Short parabolic fade, and Combined MaxNetExp corridor
RealTest 2.0 Long-Short equity curves highlighting how the short fade sleeve (dark red) surged sharply higher during the 2020 COVID selloff and 2022 bear market while struggling in the 2024 melt-up, underscoring the need for selective parabolic short rules.

Look closely at what that honest chart teaches. Even though the simple S&P 500 short fade earned strong crisis profits right in Q1 2020 and throughout 2022 (keeping the blue Combined line higher than Long-only from 2020 right through 2023!), shorting mega-cap S&P 500 stocks indiscriminately during 2024's momentum melt-up bled capital. That is why true positive-expectancy short systems target strictly extreme multi-day parabolic blowoffs with tight stop limits rather than fading normal large-cap rallies.

Upgrade Generic Short Fades into Battle-Tested Parabolic Short & Hedged Portfolios

Want a dedicated short-side RealTest strategy built specifically around extreme parabolic exhaustion rather than fighting index rallies? Inspect our RealTest Parabolic Short Selling Strategy.

To combine long, short, and defensive sleeves cleanly under unified net-exposure ceilings, explore our RealTest Strategy Combiner & Portfolio Builder and our All-Weather Low-Drawdown Portfolio.

Key terms

MaxNetExp Directive
A RealTest capacity constraint capping net directional exposure (S.LongExp minus S.ShortExp) as a percentage of allocation inside Combined or StatsGroup.
MinNetExp Directive
A RealTest lower bound on net directional exposure (for example, -40 percent) preventing a portfolio from becoming excessively net short.
Short Borrow Carry (FeesInOut)
Daily annualized stock-loan fee deducted from Side Short strategy equity via negative FeesInOut -(S.Invested * rate / 252).
Net Exposure Corridor
Bounding portfolio beta dynamically between MinNetExp and MaxNetExp while allowing gross Long plus Short exposure to adjust smoothly.
Crisis Alpha Short Sleeve
A Side Short strategy designed to generate offsetting positive returns during broad equity bear markets and volatility spikes.

Frequently asked questions

What do MaxNetExp and MinNetExp control inside RealTest's Combined section?

MaxNetExp caps net portfolio directional exposure (S.LongExp minus S.ShortExp as a percentage of S.Alloc), while MinNetExp sets the lower bound (for example, MinNetExp -40 prevents the account from ever going more than 40 percent net short).

How do you write a catastrophe stop loss for a Side Short strategy in RealTest?

For Side Short strategies, adverse price movement is UPWARD, so add ATR above FillPrice using ExitStop IF(BarsHeld >= 1, FillPrice + 3 * atr14[BarsHeld], 0). Accidentally subtracting ATR places your short stop in profit and triggers instant exits.

How do you model short-selling borrow fees realistically in RealTest?

Add FeesInOut -(S.Invested * annualRate / 252) inside your Side Short strategy (for example, 0.015 for 1.5 percent large-cap borrow fees, or 0.05 to 0.15 for harder-to-borrow small-cap parabolic shorts).

Can RealTest earn CashIntPct on cash proceeds from short sales?

Yes. Setting CashIntPct in Settings models interest earned on uninvested cash and short rebate credit automatically across the Combined account, reflecting how prime and Interactive Brokers margin accounts accrue interest on idle cash balances.

Why did ls_short_fade surge in 2020 and 2022 yet lose money in 2024?

Generic short fades on S&P 500 stocks below MA200 thrive during broad bear markets (2020 and 2022) when relief rallies fail sharply, but struggle during persistent narrow bull markets like 2024 unless restricted to extreme parabolic extensions.

How do you build a strictly dollar-neutral 0 percent net exposure portfolio in RealTest?

Pair equal-exposure Long and Short sleeves (for example, 50 percent MaxExposure Long and 50 percent MaxExposure Short) and tighten Combined to MaxNetExp 10 and MinNetExp -10 so RealTest rejects new orders that push net market beta outside a tight neutral band.

Related strategies

RealTest Parabolic Short Selling Strategy
Selective parabolic blowoff short-selling RealTest code built to earn genuine standalone edge and crisis protection.
View →
RealTest Strategy Combiner & Portfolio Builder
Test Long-Short combinations, net exposure limits, and drawdown smoothing interactively in one builder.
View →
All-Weather Low-Drawdown Portfolio
Diversified multi-sleeve RealTest portfolio engineered for smooth equity compounding across bull and bear cycles.
View →
← Back to Learn

#1 RealTest Backtests

Supercharge Your Trading Now

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

Browse RealTest Strategies