SesTrading · Answers
How to backtest a trading strategy (with a real gold backtest)
What backtesting is
The lesson defines it plainly: backtesting uses historical data, for example the past two years, to simulate how a strategy would have performed. You look at the old charts, take the trades your rules would have taken, and write each one down. The point is not a nice number; it is insight you can use to refine the strategy before it costs you anything.
It only works if the strategy is written down first. The lesson asks for specific rules for entry, exit and risk management: when and why a trade is opened and closed, and the risk-reward ratio. If a rule needs your judgement in the moment ("enter if it looks strong"), you will judge differently on old charts than on live ones, and the test means nothing.
How to backtest, step by step
- Get the data. The lesson names TradingView as a source of historical charts. Use the instrument and timeframe you will trade; check the data has no gaps on the days you test.
- Write the rules. Setup, entry, stop, target, position size, and what happens if neither stop nor target is hit. One page, no adjectives.
- Pick the period before you look. Two years is the lesson's example. Decide it in advance, so you cannot stop the test on a good stretch.
- Go candle by candle. Scroll the chart forward one candle at a time (TradingView has a replay mode) and take each trade only with what was visible at that moment.
- Journal every trade. Date, direction, entry, stop, target, size, result in money and in R, and a screenshot. The lesson insists: do not just do the backtest and think that is enough.
- Compute the statistics. Win rate, average win and loss in R, total R, profit factor, maximum drawdown, longest losing streak.
- Change one thing, test again. Use the results to fine-tune the strategy, as the lesson says, but on new data where you can, or you are only fitting the past.
The statistics that matter
| Statistic | How to compute it | What it tells you |
|---|---|---|
| Win rate | Winning trades ÷ all trades | Means little alone; read it with the average win and loss |
| Total and average R | Sum of each result ÷ the amount risked on it | Whether the rules made money per unit of risk, independent of account size |
| Profit factor | Sum of winning results ÷ sum of losing results | Above 1 = profitable before costs; 1.5 or more leaves room for costs and bad luck |
| Maximum drawdown | Largest fall from a running peak of the results, in R | How deep a losing spell the rules produced; multiply by your risk per trade |
| Longest losing streak | Most consecutive losing trades | Whether you could live with it at your risk per trade |
A real backtest: chart-pattern trades on gold
Data: COMEX gold futures (GC=F), hourly bars from Yahoo Finance grouped into 4-hour candles in UTC, 3,718 candles from 13 June 2024 to 3 November 2026, run on 4 November 2026. Gold rose from $2,332.50 to above $5,600 in late January 2026 and fell back to $3,947.20, so the test covers a long rise and a sharp fall. Yahoo's hourly series mixes futures contracts around roll dates, so a few candles show a low about $50 below the market (for example 30 July 2024); we corrected 122 wicks and 13 opening prices that sat more than four typical hourly ranges away from the candle body before counting (corrected on the evening of 4 November 2026; the first version had one double bottom fewer). The setups are the double tops, double bottoms and head and shoulders patterns measured on our chart patterns page, with the same definitions.
- Entry: at the close of the first 4-hour candle that closes beyond the neckline, counted only from the moment the pattern could be seen (six candles after its last swing, see below).
- Stop: beyond the pattern: the higher of the two tops (or lower of the two bottoms) for a double, the right shoulder for a head and shoulders.
- Target: the measured move, the pattern's height projected from the neckline. No trade if the price had already passed the target at entry.
- Time exit: at the close of the 30th candle (about five trading days) if neither stop nor target was hit. If stop and target fall inside the same candle, we count the stop.
- Costs: none included; see below for how to add them. Two patterns confirming on the same candle in the same direction count as one trade.
| Trades | Hit target | Hit stop | Time exit | Positive | Total R | Profit factor | |
|---|---|---|---|---|---|---|---|
| All trades | 36 | 19 | 9 | 8 | 23 (64%) | +7.58 | 1.76 |
| Buys (double bottoms, inverse H&S) | 19 | 13 | 1 | 5 | 15 | +9.83 | 6.11 |
| Sells (double tops, H&S) | 17 | 6 | 8 | 3 | 8 | -2.25 | 0.72 |
| Double tops and bottoms | 25 | 14 | 6 | 5 | 16 | +1.80 | 1.27 |
| Head and shoulders (both) | 11 | 5 | 3 | 3 | 7 | +5.78 | 2.74 |
Maximum drawdown was 2.46R and the longest losing streak two trades. The median amount at risk was $88.35 per ounce (0.01 lot), from $24.90 to $384.10. By year: 2024 six trades, +0.06R; 2025 twenty trades, +7.64R; 2026 ten trades, -0.12R.
Profit factor for the double tops and bottoms: wins 8.46R ÷ losses 6.66R = 1.27; for head and shoulders: wins 9.10R ÷ losses 3.33R = 2.74 (both rounded from the trade list). Over all trades: 17.56R ÷ 9.99R = 1.76.
What the backtest teaches
1. Look-ahead bias can triple a result. A swing high is only a swing high once six lower candles have printed after it. Our first run looked for the neckline break straight after the swing, before anyone could have known the swing existed, and it also put the stop at a level that by definition could not be touched for six candles. That run showed +19.0R. Counting each pattern only from the moment it was visible gave +7.0R (+7.6R after the data fix in point 5). When a backtest looks too good, look for information it used before it was available.
2. The market regime did most of the work. Buys made +9.83R with one stop out of 19; sells lost 2.25R with 8 stops out of 17. Gold rose for most of the period, so bullish patterns had the trend behind them. The same rules made almost nothing in 2024 and lost slightly in 2026. This is the lesson's main limitation in numbers: markets change behaviour, and a strategy that worked in one regime can stop working.
3. A high win rate can hide a poor payoff. The double tops and bottoms won 16 of 25 times, yet made only +1.80R, because the median win was 0.55R: with the stop beyond the top, the measured move is usually shorter than the risk. The risk-reward page works out the break-even win rate for that.
4. 36 trades is a small sample. Two or three trades either way change the conclusion. Read it as a test of the method, not as a forecast; it says nothing about how these patterns will behave from here.
5. Check the data before the strategy. The lesson warns that incomplete or inaccurate data gives misleading results, and it happened to us: Yahoo's hourly gold series mixes the expiring and the next futures contract around roll dates, so some candles show lows about $50 below the market. Those false lows created false bottoms and stops. After correcting 122 wicks and 13 opens, the test went from 35 trades and +7.03R to 36 trades and +7.58R. Look for jumps that the neighbouring candles do not share.
Adding costs
The spread and commission are paid on every trade, so convert them into R: cost per trade ÷ amount at risk per trade. With an assumed round-trip cost of $0.50 per ounce and the median risk of $88.35, that is 0.50 ÷ 88.35 = 0.006R per trade, about 0.2R over 36 trades: small here, because 4-hour stops are wide. On a 5-minute strategy with a $3 stop the same cost is 0.17R per trade, enough to turn a modest edge negative. Use your own broker's spread for the hours you trade.
Two trades from the journal
11 March 2025, buy (inverse head and shoulders). Entry $2,925.20, stop $2,897.60 (risk $27.60), target $3,034.80. Target hit: (3,034.80 - 2,925.20) ÷ 27.60 = +3.97R. With a $5,000 account and 1% risk ($50): 50 ÷ (27.60 × 100) = 0.018, rounded down to 0.01 lot; loss at the stop would have been $27.60, gain at the target 0.01 × 100 × 109.60 = $109.60.
10 March 2026, buy (double bottom). Entry $5,190.50, stop $5,005.00 (risk $185.50). Stop hit: -1R. At the smallest size, 0.01 lot, the loss is $185.50, which is 3.7% of a $5,000 account. Your journal should flag this: when the stop is wider than your 1% allows at the minimum lot, the rule is to skip the trade, not to trade it anyway. Check every trade with the lot size calculator.
Benefits and limits, from the lesson
- Benefit: you evaluate a strategy's risk and potential without investing money, and find its strengths and weaknesses before a live account.
- Benefit: you see how it behaves in different conditions, such as high volatility or high-impact news.
- Limit: a strategy tuned to perform exceptionally on past data may not perform in the future (overfitting).
- Limit: markets evolve; historical results do not guarantee future results.
- Limit: results mislead if the data is incomplete, inaccurate or not representative. Use good data and journal everything.
Key points from the lesson
- Backtesting simulates a strategy on historical data, for example two years, to refine it over time.
- Write clear rules for entry, exit and risk management first, including your risk-reward ratio.
- Journal every backtested trade and analyse profit, drawdown, win rate, losses and profit factor.
- Use the results to fine-tune the strategy; do not stop at the test.
- Our gold test: +7.6R over 36 trades, nearly all in 2025, a look-ahead mistake that had shown +19.0R and a data error that moved the result. Test the method, distrust the number.
Related summaries: how to write a trading plan (what you backtest), risk-reward ratio, stop loss, chart patterns, common trading mistakes.
Want to see how a real trading record is kept?
The Telegram bot answers in English, explains the VIP gold trades (entry, stop loss, targets) and shows where the weekly results are published, losing trades included. Trading is risky; most retail accounts lose money.
Questions people ask
What is backtesting in trading?
Applying a strategy with written rules to past price data, as if trading it live, and recording every trade to measure win rate, profit factor and drawdown. The lesson suggests about two years of data.
How many trades do I need in a backtest?
More than you think. With 36 trades, as in our gold test, two or three trades either way change the conclusion. Aim for at least 100 where the strategy allows, and across more than one market regime.
Can I backtest in TradingView?
Yes. The lesson names TradingView as a data source; its replay mode lets you move the chart forward one candle at a time so you only see what was visible then. Record the trades in a spreadsheet journal.
What is look-ahead bias?
Using information in a backtest that was not available at the moment of the trade. In our first gold run, swing points that are only confirmed six candles later were used straight away; it turned +7.0R into +19.0R.
What is a good profit factor?
Above 1 means the winners outweighed the losers before costs. Our gold pattern test had 1.76 overall, 6.11 on the buys and 0.72 on the sells. A figure from a small sample or a single trend is not reliable.
Does a good backtest mean the strategy will work?
No. Historical results do not guarantee future results; the same rules in our test made +7.64R in 2025 and -0.12R in 2026. A backtest tells you whether the idea is worth a demo account, not what it will earn.
More answers
- Is SesTrading legit?
- About & licence
- Choosing a gold signals Telegram channel
- Start trading gold with a small amount
- Copy trading vs managed account vs automated strategy
- Investing $50k–$100k for monthly income
- Gold price today (live)
- Lot size calculator (gold and forex)
- What is forex?
- How to trade gold (XAU/USD)
- Gold price history (1970 to today)
- XAU/USD explained
- Pip value calculator
- Trading for beginners: the roadmap
- Margin calculator
- Profit calculator (gold and forex)
- Gold trading strategy: a session-based plan
- Learn trading (free guides and tools)
- How to choose a forex broker (checklist)
- Trading timeframes explained (lesson)
- Common trading mistakes and how to avoid them (lesson)
- Forex trading sessions and kill zones (lesson)
- Market structure: higher highs, lower lows (lesson)
- Candlestick patterns made easy (lesson)
- Support and resistance: levels, ranges, breakout and retest (lesson)
- Fibonacci retracement: levels, discount and premium (lesson)
- Technical analysis for beginners: the tools, in order, with gold measured (lesson)
- Chart patterns: head and shoulders, double top and bottom, triangles (lesson)
- Risk-reward ratio: break-even win rates and what 1:2 and 1:3 did on gold (lesson)
- How to write a trading plan: a filled-in example for gold (lesson)
- Stop loss: where to place it, how to size the trade, and how often gold hit stops of $5 to $100
- Scalping gold: how it works, what it costs, and what 25,416 simulated 5-minute trades showed
- Gold forecast: what 51 years of prices say about the next 12 months, and what they cannot
- Best month to buy gold: what 51 years of monthly prices show (and why it is weak)
- Gold-silver ratio today (78.1) and what 26 years of it show
- Gold vs stocks: how gold behaved when the S&P 500 fell (2000-2026)
- Gold vs the US dollar: what 26 years of the dollar index show
- Gold price adjusted for inflation: 1970-2026 in today’s dollars
- Gold and interest rates: what 23 years of real yields and Fed cycles show
- How to use MetaTrader 5: a beginner's walkthrough