Monte Carlo symulacja strategii — risk visualization
Krzysiek test strategy w demo: 55% WR, expectancy +€19/trade, +€3,800 expected rocznie. Live 5% risk per trade = blew €15k account 6 mies. Re-tested Monte Carlo 1000 sims: ruin prob 25%, max DD 60%. Position sizing wrong. Reduced 1% = ruin 0.1%, DD 10%. Rok 2 profitable. Tu pokazujemy Monte Carlo framework.
Czym Monte Carlo
Monte Carlo = randomization 1000+ scenariuszy z same statistics dla risk visualization.
Setup parameters
Simulation outputs
Position sizing optimization
Excel implementation
- A1 = WR (0.55), A2 = avg win (100), A3 = avg loss (-80), A4 = trades (200)
- B1 = IF(RAND() < A1, A2, A3) — symulates 1 trade outcome
- C1 = A5 + B1 — equity update
- Drag formuły 200 rows = 1 simulation
- Copy column B-C × 1000 = 2000 cols = 1000 sims
- =PERCENTILE(final_equities, 0.5) = median, 0.05 = worst 5%, 0.01 = worst 1%
- F9 regenerates random = new 1000-sim run
Python implementation
Python bardziej powerful — full code possible 30 lines:
- import numpy as np
- np.random.random(trades) < wr → boolean array
- np.where(boolean, avg_win, avg_loss) → outcomes
- np.cumsum(outcomes) → equity curve
- Loop 1000× → results list
- np.percentile dla analysis
- matplotlib visualization spaghetti plot
Kelly criterion comparison
Kelly formula optimal mathematical: Kelly% = WR - (1-WR)/(avg win / avg loss).
55% WR, R/R 1.25 = Kelly 19%. Pełny Kelly = high variance. "Half Kelly" 9.5% recommended.
9.5% still TOO HIGH dla retail (psychological + DD tolerance). Use 1-2% per trade.
„Monte Carlo NIE optional — to standard pro level analysis. Same strategy 1000× = 1000 different equity curves. Median ≠ guaranteed. Plan around worst-case 5%, NIE median. 1% risk = ruin < 1%. 5% risk = ruin 25%."
Bootstrap z real history
Advanced: zamiast assumed distribution, use REAL trade history (100+ trades). Bootstrap = random sampling z replacement.
- Step 1: gather 100+ trades P/L
- Step 2: randomly sample 200 trades z replacement
- Step 3: compute equity curve
- Step 4: repeat 1000×
- Step 5: analyze distribution
Bootstrap captures REAL trade distribution (fat tails, clustering). More accurate niż parametric simulation.
Krzysiek case
Wnioski
Monte Carlo simulation = randomization 1000+ scenariuszy same statistics. Visualization risk strategii.
Insight: same expectancy +€19/trade = +€500 do +€7,500 yearly range. NIE deterministic.
Position sizing optimization main application. Test 0.5%, 1%, 2%, 3%, 5% risk per trade.
Sweet spot 1-2% risk = ruin prob < 1%, decent growth.
5% risk = ruin 25%. NIE viable long-term.
Excel implementation simple: RAND() + IF + cumulative. 1000 sims doable.
Python more powerful: numpy + matplotlib, 30 lines kodu, advanced features (bootstrap, regime changes).
Kelly criterion: mathematical optimal, ale pełny too aggressive. Half Kelly still high. Use 1-2%.
Bootstrap real history: more accurate niż parametric (captures fat tails, clustering).
Krzysiek case: 5% risk live = blew €15k. Monte Carlo discovery: ruin 25%. Reduced 1% = profitable rok 2. €15k saved jeśli simulated BEFORE.
Powiązane: equity curve analiza visualization, expectancy formula baseline, maximum drawdown risk metric.
Źródła i bibliografia
-
Ralph Vince Mathematics of Money Management · Monte Carlo classic www.amazon.com ↗
-
Van Tharp Trade Your Way to Financial Freedom · practical application vantharp.com ↗
-
NumPy documentation Random sampling · Python implementation numpy.org ↗
Najczęstsze pytania
Czym Monte Carlo simulation?
Monte Carlo = method probabilistic analysis. Nazwa od Monaco casino, randomization. Trading application: zamiast jednej historical sequence trades, generate 1000+ random sequences z TĄ SAMĄ statystyką (WR, avg win, avg loss). Każda sequence = different equity curve. Distribution outputs = realistic expectations. Why important: historical backtest = JEDNA realization. Variance massive. Same strategy może realize 100 different paths next year. Monte Carlo shows ALL possibilities. Example: strategia 55% WR, avg win €100, avg loss €80, 200 trades/rok. Expectancy +€19/trade = +€3,800 expected rok. ALE Monte Carlo 1000 sims: median = +€3,750 (close to expected). Worst 5% = +€500. Worst 1% = -€800. Best 5% = +€7,500. Range MASSIVE despite same expectancy. Key insight: profit NIE deterministic. Same edge może yield +€500 lub +€7,500 rocznie based luck. Need 5+ lat data dla confidence interval. Common misconception: "My strategy made €5k last year, will make €5k next year." Reality: range €1k-€10k possible same strategy.
Excel Monte Carlo setup?
Simple Monte Carlo Excel (no VBA needed): Setup: A1 = WR (e.g. 0.55). A2 = avg win (e.g. 100). A3 = avg loss (e.g. -80). A4 = trades (e.g. 200). A5 = starting capital (e.g. 10000). Row 1 (trade 1): B1 = IF(RAND() < A1, A2, A3). Simulates 1 trade outcome. Equity: C1 = A5 + B1. Subsequent: B2 = IF(RAND() < A1, A2, A3), C2 = C1 + B2. Drag down 200 rows. Final equity: C200 = final balance for 1 simulation. Multiple sims: copy formula B-C 1000 times (column B-C, columns D-E, F-G, etc.). 1000 simulations = 2000 columns. Excel handles OK. Analysis: =PERCENTILE(final_equities, 0.5) = median. =PERCENTILE(final_equities, 0.05) = worst 5%. =PERCENTILE(final_equities, 0.01) = worst 1%. Max DD: for each sim, compute peak-to-trough drawdown. Distribution of max DD. Random regen: F9 key regenerates ALL random numbers. Each press = new 1000-sim run. Limitation: assumes independence trades (NIE clustered drawdowns). Real markets clustered. Add correlation factor advanced.
Python Monte Carlo implementation?
Python Monte Carlo bardziej powerful niż Excel. Libraries: numpy (random sampling), matplotlib (visualization), pandas (data handling). Code structure: import numpy as np. Define parameters: wr=0.55, avg_win=100, avg_loss=-80, trades=200, sims=1000. Function: def simulate_strategy(wr, avg_win, avg_loss, trades): trades_outcomes = np.where(np.random.random(trades) < wr, avg_win, avg_loss). equity = 10000 + np.cumsum(trades_outcomes). return equity. Run sims: results = [simulate_strategy(0.55, 100, -80, 200) for _ in range(1000)]. Analysis: final_equities = [r[-1] for r in results]. median = np.median(final_equities). worst5 = np.percentile(final_equities, 5). worst1 = np.percentile(final_equities, 1). max_dds = [max_drawdown(r) for r in results]. Visualization: matplotlib plot all 1000 equity curves overlap + percentile bands. Spaghetti plot.
Advanced features: (1) Variable WR (drift over time). (2) Cluster drawdowns (regime changes). (3) Position sizing optimization (test multiple risk %). (4) Bootstrap from REAL trade history (NIE assumed distribution).
Position sizing optimization?
Position sizing optimization = main Monte Carlo application. Test multiple risk %: 0.5%, 1%, 2%, 3%, 5% per trade. Run 1000 sims each. Compare outcomes: 0.5% risk: median equity €11k, max DD 5%, ruin prob 0%. Slow growth. 1% risk: median €12k, max DD 10%, ruin prob 0.1%. Sweet spot most strategies. 2% risk: median €15k, max DD 22%, ruin prob 2%. Aggressive but viable. 3% risk: median €18k, max DD 38%, ruin prob 8%. High risk. 5% risk: median €25k, max DD 60%, ruin prob 25%. Likely blow-up. Decision framework: Goal = max growth WHILE keeping ruin prob < 1%. Usually 1-2% risk per trade. Beyond = exponential ruin risk. Kelly criterion: optimal mathematical position sizing. Formula: Kelly% = WR - (1-WR)/(avg win / avg loss). 55% WR, R/R 1.25 → Kelly 19%. ALE pełny Kelly = high variance. "Half Kelly" (9.5%) recommended. Still too high dla retail. Use 1-2% per trade. Real-world example: Krzysiek tested strategy 5% risk per trade w live = blew €15k account 6 mies. Re-tested Monte Carlo = ruin prob 25%. Reduced 1% = profitable rok 2.