Skip to main content
← Back to Academy
LESSON 3
🔬

The Backtester & Monte Carlo

🧪 Backtest Scientist
~5 min

What you'll learn

The Backtester lets you test a strategy on historical data. You choose an asset (BTC, ETH, SOL...), a time period, and the backtester simulates the trades the strategy would have made.

The backtest trap: A perfect backtest guarantees NOTHING for the future. This is the overfitting problem — a strategy over-optimized for the past fails on new data. It's like a student who memorizes answers from a past exam: 100% on that exam, 0% on the next.

Monte Carlo simulation helps detect this. It runs 1000 simulations by randomly shuffling the order of trades (bootstrap resampling). If your strategy is robust, it will perform well in most of the 1000 parallel universes. If it only works in one specific order, that's a red flag.

The Robustness Score summarizes everything in one number. It combines: percentage of profitable simulations, return stability, and Sharpe Ratio consistency across simulations. A score > 70% indicates a more robust strategy in these simulations, not a guarantee.

Practical exercise: go to the Backtester, test a strategy of your choice on BTC, then run Monte Carlo. Compare with Buy & Hold and note the robustness gap.

Monte Carlo in Practice

Concretely, what does "1,000 simulations" mean? Imagine your strategy made 50 trades in 2025. Monte Carlo takes these 50 trades and shuffles them randomly 1,000 times. Simulation #1: the winning trade comes first, then 3 losers. Simulation #2: 5 losers in a row, then a winning streak. Simulation #738: trades arrive in a completely different order. Each simulation gives a different final PnL.

If your strategy ends positive in 800 out of 1,000 simulations, your robustness score is 80% — it's robust: the result depends little on trade order. If it only ends positive in 450 out of 1,000 simulations, your score is 45% — it's fragile. The strategy depends on a specific order to work, which probably won't repeat.

Key thresholds:

- 90-100%: Very robust — positive in almost all simulations
- 70-90%: Robust — positive in most simulations
- 50-70%: Fragile — dependent on specific conditions
- < 50%: Dangerous — the strategy has as much chance of losing as winning

Watch Out for Overfitting

Overfitting is a classic backtesting trap. It's when a strategy is so optimized for past data that it becomes useless for the future. Signs of overfitting:

- A too perfect backtest (PnL > 100%, zero drawdown) — be suspicious!
- A low Monte Carlo score despite a good backtest (sign that results depend on exact order)
- Ultra-specific parameters (e.g., buy when RSI = 31.7 and volume > 1247) instead of general rules

The golden rule: a perfect backtest on the past guarantees nothing about the future. That's why Monte Carlo exists — to separate real robustness from luck.

Training period and sealed period: the cut-off date

Monte Carlo shuffles trades you already know: it says nothing about a period the strategy has never seen. Before any test, pick a cut-off date. Data before that date is for training: that is where you search for and tune your rule. Data after the cut-off is the sealed period: you do not touch it until the rule is frozen, then you run it once, without retuning any parameter.

A rule that shines before the cut-off and collapses after it was probably fitted to past noise. A rule that holds after the cut-off has no guarantee for the future, but it passed the test that matters most: working on data it had never seen.

Fees change the verdict

Every buy and every sell pays fees, plus a price gap (spread, slippage). On a strategy that trades a lot, a few tenths of a percent per round trip are enough to turn a positive result into a loss. Always test with realistic fees, then with slightly higher fees: if the result only holds with zero fees, the rule does not hold.

Try it without an account

The online judge runs a Pine strategy on a period it has never seen, fees included. The history replay scrolls the past candle by candle without showing what comes next: good practice for deciding without knowing the future.

🔬 LIVE FROM THE LAB

Practical exercise

Explore the real page to consolidate your knowledge

Open The Backtester & Monte Carlo ↗

QUIZ

Next lesson →

CHOOSE YOUR AI MENTOR

Your mentor will guide you through the rest of the course
🧠
CLAUDE
The cautious strategist
⚡
GROK
The rebel contrarian
🚀
GPT
The methodical technician
💎
GEMINI
The bias-balancing mentor
🔮
DEEPSEEK
The calibrated aggressor
🔍
PERPLEXITY
The data researcher