Backtesting
Test a strategy against historical data with real costs before risking money — and learn to read the results like a pro.
Backtesting means «testing backwards»: taking a strategy and seeing how it would have behaved in the past, using real historical data, candle by candle. It's the validation step before putting money on the line. The difference between a serious backtest and a toy one comes down to one thing: whether it includes the real costs. TradingNote always includes them (commission, swap, spread and slippage), so the result is realistic and not an optimistic fantasy.
How it works, step by step
- 1
Choose what to test
You select the algorithm or strategy, the instrument (EURUSD, US30, XAUUSD…), the timeframe (M5, H1, D1…) and the historical date range to test over.
- 2
Define your account costs
Spread, commission per lot and swap. If you test against a connected account, TradingNote uses that broker's real specs; if it's generic, it uses the instrument's default values that you can adjust.
- 3
Run the backtest
The platform simulates, candle by candle, every trade the strategy would have made, applying costs on each entry and exit, and charging swap for every night the position stays open.
- 4
Read the results
You get the equity curve, the metrics (Sharpe, Profit Factor, Drawdown…) and the full list of simulated trades, to judge whether the strategy is worth it.
Real costs: the detail that changes everything
Most backtests online ignore costs, which is why they show beautiful curves that never repeat in real life. A scalping strategy can look profitable with no costs and lose money the moment you subtract spread and commission. These are the four costs TradingNote subtracts:
| Cost | What it is | Who it hurts most |
|---|---|---|
| Spread | The gap between buy and sell. You pay it on entry. | Scalping and low timeframes (M1-M5). |
| Commission | Fixed charge per lot the broker bills to open and close. | High-frequency strategies. |
| Swap | Interest for holding the position overnight. | Swing and long-held positions (days/weeks). |
| Slippage | The gap between the price you asked for and the one you got. | News and low liquidity (rollover, early hours). |
Golden rule: if a strategy is only profitable with zero costs, it's not a strategy, it's a mirage. The real-cost backtest is precisely the filter that separates what works from what only looks pretty.
Two ways to run a backtest
You test an algorithm you already created or explored, with its entry/exit rules and indicators. Ideal to validate a specific algorithm before taking it live or into a portfolio. It connects directly with the Algorithm Tester, where you can also optimize parameters and run the robustness validation.
Manual backtesting replays the historical chart as if time were moving forward, and you decide when to enter and exit. It's for training your discretionary judgment, validating an idea by hand before coding it, or studying how an asset behaved in a specific period. It's the «flight simulator» version.
The metrics, explained in plain language
| Metric | What it measures | What to look for |
|---|---|---|
| Sharpe ratio | How much you earn per unit of risk (volatility) you take. | Above 1 is good; above 2, excellent. But beware overfitting. |
| Profit Factor | How much you win per dollar lost (gross profit / gross loss). | Above 1 is profitable; 1.5–2.5 is solid and sustainable. |
| Max drawdown | The worst drop from a peak to a trough. Your maximum pain. | The lower the better. Ask yourself: could I stomach that streak without quitting? |
| Win rate | The percentage of winning trades. | Not the most important: 40% with good R:R beats 70% with bad. |
| Number of trades | How many trades the backtest generated. | Fewer than ~100 isn't statistically reliable: it could be luck. |
TradingNote computes Sharpe with professional methodology (daily returns × √252, López de Prado style). That's why its values don't match MetaTrader's: they're comparable to academic literature, not to another platform. A Sharpe of 1.5 here is a «real» 1.5 Sharpe.
A subtlety that confuses many: net vs gross
When you compare backtest metrics with your real account, make sure you compare the same thing. TradingNote reports each trade's NET result — the one that already includes commission and swap — not the gross. It's the exact equivalent of the «profit» you see at your broker. If you mix in the gross somewhere, the numbers won't add up.
// El resultado de cada operación = neto (incluye comisión + swap)
const resultado = operacion.pnl // ✅ lo que cuadra con tu broker
// NO el bruto:
const resultado = operacion.profit // ❌ no incluye costos → infla las métricas«Light» vs «heavy» backtests
A «light» backtest is a single run over a reasonable range: instant and unlimited. A «heavy» backtest (multi-year ranges or many parameter combinations at once) consumes a monthly allowance based on your plan, because it runs on dedicated infrastructure. If you run out, you continue next month or upgrade.
Mistake #1: trusting a single backtest
An excellent backtest does NOT guarantee future profits. It's easy to find, by pure chance, a parameter combination that looks perfect in the past and fails the moment the market shifts. That's called overfitting, and it's the graveyard of most strategies.
Never take an algorithm live based only on a pretty backtest. Always run it through the three orthogonal robustness filters in «My Algorithms»: DSR (discounts sampling luck), Walk-Forward (tests it on data it never saw) and Multiverse (subjects it to thousands of synthetic markets). Only what survives all three deserves your money.