Equity Curve Trading, StratData, and Drawdown Pausing in RealTest (Validated Code)
Never calculate Avg(S.Equity, 50) inside RealTest's Data section or pause a strategy using its own equity curve, because Data runs pre-test and a paused strategy's flatlined equity can never cross back above its moving average to resume. Instead, run an always-on shadow reference strategy, compute its equity SMA in StratData, and gate or throttle your live strategy via Extern(@shadow_ref, ecActive).
- S.Equity cannot be referenced inside the Data section because Data calculates across symbols before the backtest starts; per-strategy equity indicators belong inside RealTest 2.0's StratData section.
- Pausing a strategy whenever its own S.Equity drops below Avg(S.Equity, 50) creates a permanent freeze trap because flatlined equity stays equal to or below its SMA forever unless tracked separately.
- Running an always-on shadow reference strategy (mr_shadow_ref) alongside a gated live strategy referencing Extern(@mr_shadow_ref, ecActive) solves the resume problem cleanly inside a single RealTest script.
- Guard the initial warmup window with S.Number <= ecMaLen so the equity moving average does not evaluate to NaN and block all entries during the first 50 trading days.
- Validated in RealTest 2.0 across 2010 to 2024 on multi-asset ETFs, hard pausing below the 50-day equity SMA (mr_ec_paused) actually worsened drawdown (-10.35 percent vs -9.42 percent) and cut returns ($111,039 vs $123,015) by missing sharp post-drawdown snapbacks.
- Soft drawdown throttling (mr_ec_throttled cutting position size by 50 percent below the shadow equity SMA) lowered max drawdown to -8.35 percent while preserving $116,568 ending equity across 654 trades.
Trading the equity curve (pausing or scaling down a strategy whenever its own equity drops below a 50-day moving average) appears in 57 forum discussions and is one of the trickiest mechanics to code cleanly in RealTest. Traders consistently hit two walls. First, putting Avg(S.Equity, 50) inside the Data section fails because Data executes before any equity curve exists. Second, even after moving the formula into Strategy, pausing a strategy off its own S.Equity locks it in cash permanently because flatlined equity never rises back above its moving average to trigger re-entry!
Every scope rule below follows the official RealTest StratData documentation, and the complete shadow-strategy comparison was executed in RealTest 2.0 across 15 years of ETF data to test hard pausing versus soft 50 percent drawdown throttling honestly.
Why StratData Plus a Shadow Strategy Solves Equity Curve Trading
RealTest 2.0's StratData section runs once per strategy per test date inside the simulation loop. Unlike Data (pre-test per symbol) and TestData (in-test per symbol), StratData has a native strategy context initialized automatically, allowing clean equity-curve indicators like ecMa: Avg(S.Equity, 50) and ecActive: S.Equity >= ecMa that also become available in Results and Graphs.
| Equity Curve Approach | How RealTest Evaluates It | What Happens During a Drawdown |
|---|---|---|
Self-referencing pause (S.Equity >= Avg(S.Equity, 50)) |
Checks live strategy's own equity | Permanent freeze trap (flatlined equity cannot recover above its SMA cleanly) |
Shadow Strategy Hard Pause (Extern(@mr_shadow_ref, ecActive)) |
Shadow strategy trades continuously; live strategy pauses off shadow state | Pauses cleanly in bear patches and resumes automatically once shadow strategy turns up |
Shadow Strategy Soft Throttle (50% Quantity when shadow below SMA) |
Live strategy stays active at half size when shadow is below SMA | Cuts worst drawdown smoothly while still capturing fast post-slump recoveries |
Notice one essential detail when running a shadow strategy inside a live multi-strategy script. In backtest research, running mr_shadow_ref and mr_ec_throttled in the same file lets you plot both equity curves side by side immediately. When moving to live brokerage execution (or computing clean Combined stats), exclude the shadow sleeve from live capital by keeping it in a separate StatsGroup or checking Combined constraints carefully (see our RealTest multi-strategy combining guide).
Complete Validated RealTest Script (Shadow vs Hard Pause vs 50% Throttle)
Below is a complete, runnable RealTest 2.0 script comparing all three behaviors on identical ETF mean-reversion entries and costs via Template: mr_ec_base. Notice the warmup guard S.Number <= ecMaLen inside EntrySetup and Quantity. Without that guard, Avg(S.Equity, 50) returns NaN during the first 50 trading days, which prevents any entries from firing at the start of the test (just like pre-inception Extern() NaNs covered in our RealTest Extern() and regime filter guide).
Notes:
Equity curve trading in RealTest using a continuously running shadow
strategy, StratData equity moving averages, and Extern(@shadow, ...)
so paused sleeves automatically resume when the underlying edge recovers.
Settings:
DataFile: C:\RealTest\Data\MainETF.rtd
StartDate: 2010-01-01
EndDate: 2024-12-31
AccountSize: 100000
BarSize: Daily
Parameters:
numPos: 4
ecMaLen: 50
Data:
isUniv: Symbol = $SPY or Symbol = $VEU or Symbol = $GLD or Symbol = $TLT or Symbol = $VNQ or Symbol = $XLE or Symbol = $XLP or Symbol = $IYH
atr14: ATR(14)
rsi2: RSI(2)
ma200: Avg(C, 200)
entrySig: isUniv and C > ma200 and rsi2 < 15
StratData:
ecMa: Avg(S.Equity, ecMaLen)
ecActive: S.Equity >= ecMa
Template: mr_ec_base
Side: Long
EntryLimit: C - 0.35 * atr14
EntryTime: Intraday
SetupScore: 100 - rsi2
Quantity: 100 / numPos
QtyType: Percent
MaxPositions: numPos
MaxExposure: 100
Commission: Max(1, Shares * 0.005)
LimitExtra: 0.001 * C
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. Always-on shadow strategy tracks true underlying equity recovery
Strategy: mr_shadow_ref
Using: mr_ec_base
EntrySetup: entrySig
// 2. Hard pause when shadow equity dips below its 50-day SMA; resumes on recovery
Strategy: mr_ec_paused
Using: mr_ec_base
EntrySetup: entrySig and (S.Number <= ecMaLen or Extern(@mr_shadow_ref, ecActive))
// 3. Soft drawdown throttle cutting sizing in half below shadow equity SMA
Strategy: mr_ec_throttled
Using: mr_ec_base
EntrySetup: entrySig
Quantity: IF(S.Number <= ecMaLen or Extern(@mr_shadow_ref, ecActive), 100 / numPos, 50 / numPos)
Charts:
MA200: ma200
Validated 2010 to 2024 Empirical Result (Hard Pause vs Soft Throttle)
Running all three strategies side by side in RealTest 2.0 from January 2010 through December 2024 produced a striking empirical result that challenges common trading folklore about hard equity-curve switches.
| Strategy Variant (2010 to 2024) | Completed Trades | Ending Equity ($100k start) | Maximum Daily Drawdown |
|---|---|---|---|
mr_shadow_ref (Always-On Baseline) |
644 | $123,015 | -9.42% |
mr_ec_paused (Hard Pause Below 50-Day Equity SMA) |
412 | $111,039 | -10.35% |
mr_ec_throttled (50% Size Throttle Below 50-Day Equity SMA) |
654 | $116,568 | -8.35% |

On mean-reversion systems, the strongest bounces frequently arrive right after a brief equity slump, which is the exact moment a hard equity-curve switch turns entries off. If you want smoother drawdowns without forfeiting recovery trades, soft position-size throttling (cutting Quantity to 50 percent below the equity SMA) or combining uncorrelated market styles outperforms binary on/off equity switches across nearly every regime. For deeper sizing controls, review our RealTest position sizing guide and RealTest Data vs TestData vs StratData reference.
Controlling Drawdowns Without Breaking Your Edge
True drawdown reduction comes from structural diversification (pairing mean reversion, trend, rotation, and defensive filters) rather than curve-fitting a single equity moving average. To inspect clean templates locally, visit our free RealTest strategy and code library or download the Free Mean-Reversion Strategy for RealTest and Python.
If you want complete, out-of-sample validated low-drawdown RealTest systems with full open source code, examine our All-Weather Low-Drawdown Portfolio and RealTest Low Drawdown Nasdaq Mean Reversion Strategy. You can also explore multi-strategy sleeve combinations directly inside our RealTest Strategy Combiner & Portfolio Builder or browse the full RealTest Portfolios collection.
Key terms
- StratData Section
- A RealTest 2.0 script section calculating per-strategy daily series inside the test loop with native access to S.Equity and S.DDPct for equity-curve indicators, Results, and Graphs.
- Shadow Strategy
- An always-on reference Strategy inside RealTest whose continuous equity curve drives Extern(@shadow, ...) pause or throttling rules on a companion strategy.
- S.Number
- A RealTest daily test statistic counting the sequential bar number since StartDate, used to bypass initial NaN warmup windows in equity moving averages.
- Equity Curve Throttling
- Scaling Quantity down (for example to 50 percent size) whenever a shadow strategy's equity trades below its moving average rather than shutting entries off completely.
- Equity Freeze Trap
- A common backtesting bug where pausing a strategy off its own S.Equity causes its equity curve to flatline permanently so it can never cross back above its SMA.
Frequently asked questions
Why does Avg(S.Equity, 50) fail inside the Data section in RealTest?
Data section arrays calculate across all symbols before the backtest simulation begins, so strategy equity curves do not exist yet. Put per-strategy equity indicators inside RealTest 2.0's StratData section instead.
How do you make a paused RealTest strategy resume after its equity curve recovers?
Run an always-on shadow reference strategy (mr_shadow_ref) that trades continuously, compute ecActive as S.Equity >= Avg(S.Equity, 50) inside StratData, and gate your live strategy using Extern(@mr_shadow_ref, ecActive). Because the shadow strategy never stops trading, it automatically detects when the edge recovers.
Why does a strategy paused on its own equity curve stop trading forever?
Once a strategy stops taking new trades, its own S.Equity line goes completely flat. Its moving average gradually catches up to that flat line, preventing a clean upward crossover unless an independent shadow strategy keeps tracking simulated performance.
What does S.Number <= ecMaLen do in an equity curve filter?
During the first 50 bars of a backtest, Avg(S.Equity, 50) returns NaN because fewer than 50 equity points exist. Adding S.Number <= ecMaLen allows normal trading during the initial warmup window before the equity SMA filter engages.
Is hard pausing or 50 percent size throttling better for equity curve trading?
In our 2010 to 2024 RealTest validation on ETF mean reversion, hard pausing worsened max drawdown (-10.35 percent vs -9.42 percent) by missing post-slump recoveries, whereas soft 50 percent size throttling reduced max drawdown cleanly to -8.35 percent while preserving most of the strategy's profit.
What is the difference between TestData and StratData in RealTest 2.0?
TestData calculates once per symbol per test date and requires Extern(@strategy_name, ...) to read strategy variables. StratData calculates once per strategy per test date with a built-in strategy context (ideal for S.Equity and S.DDPct indicators) and can be plotted directly in Graphs and Results.