SesTrading

SesTrading · Answers

How to backtest a trading strategy (with a real gold backtest)

By Saad El Soussi, UAE-authorized finfluencer · Updated 2026-11-08

Backtesting means taking a strategy with written rules for entry, stop, target and size, applying it to past price data (the lesson suggests about two years), and recording every trade in a journal so you can measure win rate, profit factor and drawdown before you risk money. We ran one on gold: chart-pattern trades on the 4-hour chart, June 2024 to November 2026. The result was 36 trades, 23 positive, +7.6R in total (R = the amount risked per trade), but almost all of it came in 2025: 2024 was +0.1R and 2026 so far -0.1R. Our first run showed +19.0R because of a look-ahead mistake, which is the most useful lesson on this page.

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

  1. 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.
  2. Write the rules. Setup, entry, stop, target, position size, and what happens if neither stop nor target is hit. One page, no adjectives.
  3. 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.
  4. 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.
  5. 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.
  6. Compute the statistics. Win rate, average win and loss in R, total R, profit factor, maximum drawdown, longest losing streak.
  7. 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

StatisticHow to compute itWhat it tells you
Win rateWinning trades ÷ all tradesMeans little alone; read it with the average win and loss
Total and average RSum of each result ÷ the amount risked on itWhether the rules made money per unit of risk, independent of account size
Profit factorSum of winning results ÷ sum of losing resultsAbove 1 = profitable before costs; 1.5 or more leaves room for costs and bad luck
Maximum drawdownLargest fall from a running peak of the results, in RHow deep a losing spell the rules produced; multiply by your risk per trade
Longest losing streakMost consecutive losing tradesWhether 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.

TradesHit targetHit stopTime exitPositiveTotal RProfit factor
All trades36199823 (64%)+7.581.76
Buys (double bottoms, inverse H&S)19131515+9.836.11
Sells (double tops, H&S)176838-2.250.72
Double tops and bottoms25146516+1.801.27
Head and shoulders (both)115337+5.782.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

Key points from the lesson

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.

Authorized in the UAESaad Nizar El Soussi, founder of SesTrading, is listed by the UAE Capital Market Authority as an authorized finfluencer (entry 193, added 24 September 2026). Check the official list.

More answers