Simulating Intraday Trailing Drawdown Failure Rates vs Static Limits in Python

Leader ●1 ●15 ●39
calendar_today ago • schedule1 min read
— Originally published at guetaquant.com

Most backtest engines evaluate risk against a static starting balance. If you start with $100,000 and set an 8% maximum loss limit, the floor stays at $92,000 regardless of whether the account climbs to $105,000.

Proprietary evaluation accounts often replace that static floor with an intraday equity trailing drawdown. Every time open floating profit pushes equity to a new high-water mark, the liquidation floor moves up behind it.

Static drawdown vs intraday equity trailing drawdown comparison

For the full Spanish quantitative guide and interactive recovery calculator, see Asimetría matemática del drawdown.

Modeling the path-dependent trailing floor

Because a trailing limit depends on the exact order of wins and losses (and intra-trade excursions), closed-form risk-of-ruin formulas understate failure probability. A Monte Carlo loop over 5,000 synthetic 100-trade paths shows the divergence directly:

import random


def compare_drawdown_rules(
    n_runs: int = 5000,
    n_trades: int = 100,
    win_rate: float = 0.45,
    rr: float = 1.8,
    risk_per_trade: float = 0.01,
    dd_limit: float = 0.08,
    seed: int = 42,
) -> tuple[float, float]:
    """Compare static vs trailing drawdown breach rates."""
    rng = random.Random(seed)
    static_breaches = 0
    trailing_breaches = 0

    for _ in range(n_runs):
        equity = 1.0
        peak = 1.0
        hit_static = False
        hit_trailing = False

        for _ in range(n_trades):
            if rng.random() < win_rate:
                equity *= 1.0 + risk_per_trade * rr
            else:
                equity *= 1.0 - risk_per_trade

            if equity > peak:
                peak = equity

            if equity <= 1.0 - dd_limit:
                hit_static = True
            if (peak - equity) / peak >= dd_limit:
                hit_trailing = True

        static_breaches += int(hit_static)
        trailing_breaches += int(hit_trailing)

    return static_breaches / n_runs, trailing_breaches / n_runs


static_rate, trailing_rate = compare_drawdown_rules()
print(f"Static breach: {static_rate:.2%} | Trailing breach: {trailing_rate:.2%}")

Even with positive expectancy (0.45 * 1.8 - 0.55 = +0.26R per trade), sizing at 1% of nominal balance treats a $100,000 account as if it had $100,000 of risk capacity. In practice, the real risk budget is the $8,000 buffer, so a 1% nominal trade consumes 12.5% of the allowed drawdown in one position.

Dropping risk per trade to 0.25% to 0.50% of nominal balance and halving risk at 4% drawdown keeps the strategy inside both static and trailing bounds across normal losing streaks.

Educational and statistical analysis only (SFC Colombia Decreto 2555 de 2010). No financial advice or trade signals.

Want more #python & #algorithms deep dives?

Join 6,128+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

SEO Rates Philippines 2026: Costs & Packages | FloxoLab

floxolab - Oct 18

When One Python Process Fails, You Need to See All of Them

Tom Smithverified - Nov 23

Static vs Dynamic Websites for SEO

floxolab - Sep 8

Stop trusting verdicts your policy no longer supports

VEACESLAV - Dec 1
chevron_left
1.8k Points • 55 Badges
Bogotá, Colombia • guetaquant.com
19Posts
2Comments
15Connections
Founder & Lead Quantitative Engineer at Gueta Quant (https://guetaquant.com).

I design open-source... Show more

Commenters (This Week)

4 comments
3 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!