Most position-sizing calculators stop at pip value and fixed balance percentages. That shortcut misses the real failure mechanism in two-step proprietary trading evaluations: variance clustering against an intraday daily loss cap. I built a zero-dependency simulator for TradeMathLab covering 5,000 randomized paths. It runs locally in your browser.
Why Seeded PRNG Matters for Financial Simulators
Using Math.random() inside an interactive calculator breaks reproducibility because refreshing the page shifts pass odds on identical inputs. A 32-bit seeded generator solves this cleanly in ten lines of code, letting traders share exact URL parameters while keeping statistical variance realistic across 5,000 sequential trials.
function mulberry32(a) { return function () { a |= 0; a = (a + 0x6d2b79f5) | 0; var t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } Reproducibility matters for debugging too. With a fixed default seed (1337) and 23 unit assertions under Node.js, I can verify that changing risk per trade or target thresholds causes exact, predictable deltas. Random jitter never hides a logic regression.
Here is the core two-step evaluation state machine:
function runPhase(targetPct, opts, rng) { var eq = 100, dayStart = 100; var w = opts.winRatePct / 100; var dayLen = Math.max(1, Math.round(opts.tradesPerDay)); for (var i = 1; i <= 400; i++) { eq += rng() < w ? opts.riskPerTradePct * opts.riskReward : -opts.riskPerTradePct; if (eq <= 100 - opts.maxDdPct) return { ok: false, reason: "MAX", trades: i }; if (eq <= dayStart - opts.dailyDdPct) return { ok: false, reason: "DAILY", trades: i }; if (eq >= 100 + targetPct) return { ok: true, reason: "PASS", trades: i }; if (i % dayLen === 0) dayStart = eq; } return { ok: false, reason: "TIMEOUT", trades: 400 }; } Every path resets dayStart after tradesPerDay executions (default 3). Only accounts clearing Phase 1 enter Phase 2, which mirrors real funding rules without optimistic shortcuts.
What 5,000 Simulated Sequences Prove About Risk Scaling
Running simulateChallenge() at 45% win rate and 1:2 risk-to-reward yields a healthy +0.35R mathematical expectancy per trade. Yet across an 8% Phase 1 target, 5% Phase 2 target, 10% overall limit, and 5% daily loss limit, pass rates collapse once risk crosses 1.5%.
| Risk / Trade | Phase 1 Pass | 2-Step Pass Rate | Fail: Max DD | Fail: Daily DD | Avg Trades to Pass |
|---|---|---|---|---|---|
0.5% | 99.78% | 99.72% | 0.28% | 0.00% | 76 |
1.0% | 96.86% | 93.98% | 6.02% | 0.00% | 36 |
1.5% | 91.24% | 84.88% | 15.12% | 0.00% | 24 |
2.0% | 65.14% | 46.50% | 0.00% | 53.50% | 10 |
2.5% | 51.04% | 33.40% | 0.00% | 66.60% | 6 |
Look closely at the jump between 1.5% and 2.0%. It breaks sharply. Below 1.66% risk with three trades a day, three straight losses inside one session cannot hit a 5% daily limit (3 × 1.5% = 4.5%). At 2.0% risk, three consecutive losses inside one day produce a -6.0% drop. The account terminates immediately.
Daily drawdown takes over completely. Total failures shoot from 15.12% at 1.5% risk up to 53.50% at 2.0% risk — all driven by intraday 5% breaches rather than the 10% overall ceiling. At 50% win rate (+0.50R), the exact same pattern cuts pass odds from 100.00% (0.5% risk) down to 59.58% (2.0% risk). The pattern holds.
Dynamic Intraday Sizing Prevents Trade-Three Breaches
Static balance percentages fail because they assume your daily buffer resets after every order. On a $100,000 account with a 5% daily cap ($5,000), taking a -$3,500 morning loss leaves only $1,500 of usable intraday margin before liquidation.
var dailyLimitUsd = balance * (dailyDdPct / 100); var remainingDailyUsd = dailyLimitUsd + dayPnl; var maxConsecutiveLosses = remainingDailyUsd > 0 ? Math.floor(remainingDailyUsd / riskAmount) : 0; Under those numbers, keeping a 1% stake ($1,000) equals 4.00 standard lots on EUR/USD ($10/pip, 25-pip stop) and leaves exactly 1 full stop before account breach. Dropping risk to 0.25% ($250, or 1.00 lot) restores a 6-trade survival cushion until midnight reset.
Browser Performance Without Framework Bloat
Running 5,000 Monte Carlo paths across up to 400 bars per phase takes under 15 milliseconds in V8 without Web Workers or bundlers. Keeping the entire simulator module at 7,870 bytes lets every calculator page load under a strict 60 KB code budget with instant state synchronization via URLSearchParams.
Note: All calculations and interactive utilities on TradeMathLab are strictly mathematical and educational tools, not financial or investment advice.

