Part 3: Using them together · Chapter 11 of 14 · 12 min

Parameters and optimization: the best of fifty-four

What happens when you search for the "right" numbers of an indicator: 54 pairs of moving averages on the same candles give from −1,235 to +1,336 dollars per ounce, the peak has neighbors that earn half, and the best of 54 tries shows up even on shuffled prices.

Every indicator has numbers to choose

The RSI is computed over 14 candles, the MACD uses 12, 26 and 9, Bollinger bands 20 and 2, the fast average 20 and the slow one 50. These values are habit. Nobody derived them from gold, and whoever changes them gets a different indicator with the same shape. Optimizing means trying many values on history and keeping the one that earned the most.

The procedure looks scientific and has one simple flaw: among many tries, one does well by necessity. The rest of the chapter measures how well.

The test: 54 pairs of averages on the same candles

System: two exponential moving averages (EMA) of H4 closes. When the fast one crosses the slow one upward you buy, when it crosses downward you sell short, and you stay in the market all the time. Cost of 0.30 dollars per ounce at every position change. Period: December 2025 - October 2026, 1,772 H4 gold candles (XAUUSDT perpetual future).

The grid: fast 5, 8, 10, 12, 15, 20, 25 or 30 candles; slow 20, 26, 30, 40, 50, 60, 80 or 100, with the slow at least one and a half times the fast. That gives 54 pairs. Result in dollars per ounce, summing all trades:

PairTradesTotal
Best15/4030+1,336 $
5/2092+1,127 $
5/3068+1,100 $
5/2676+1,053 $
8/2068+980 $
Worst30/6028−430 $
25/10023−489 $
15/10027−554 $
30/10023−641 $
20/10029−1,235 $

Pairs with a positive total are 44 out of 54, the median is +543 $. The classic 20/50 pair gives +433 $ and ranks 31st of 54. The best one, 15/40, has 11 winning trades out of 30 (37%): the usual shape of a trend-following system, with many small losses and a few long trades that pay for everything.

Part of the full table, with the total in $ for each pair (slow in columns):

FastSlow 30Slow 40Slow 50Slow 80Slow 100
5+1,100+592+249+377+392
10+678+650+605+443−258
15+594+1,336+812+452−554
20+813+810+433−293−1,235
30+251+242−641

Figure 1 shows the 15/40 on H4 candles from 29 January to 8 February 2026: the long opened on 5 January closes on 31 January at 4,906.48 with +464 $, the next short closes on 7 February at 4,965.58 with −59 $. Figure 2 shows the same candles with the 20/100: in the same stretch it closes three losing trades in a row (−462, −231 and −146 $). Same rule, same candles, two other numbers.

Figure 1. EMA 15/40 on H4 candles from 29 January to 8 February 2026: the long closes on 31 January at 4,906.48 with +464 $, the next short −59 $.Data: gold, XAUUSDT perpetual future (real candles) · 4 hours (H4) · from 29 Jan 2026 00:00 UTC to 8 Feb 2026 20:00 UTC.
Read the chart in words

H4 gold chart from 29 January to 8 February 2026 with the EMA 15 (blue) and the EMA 40 (dashed pink). Labels on the two closed trades with their result in dollars per ounce.

WhenWhatPrice
29 Jan 2026 00:00 UTCEMA 155,259.61 → 4,963.56
29 Jan 2026 00:00 UTCEMA 405,092.41 → 4,942.81
31 Jan 2026 04:00 UTClong closed: +464 $4,906.48
7 Feb 2026 12:00 UTCshort closed: −59 $4,965.58

Times in UTC.

Figure 2. EMA 20/100 on the same candles: three losing trades in a row (−462, −231 and −146 $ per ounce).Data: gold, XAUUSDT perpetual future (real candles) · 4 hours (H4) · from 29 Jan 2026 00:00 UTC to 8 Feb 2026 20:00 UTC.
Read the chart in words

H4 gold chart from 29 January to 8 February 2026 with the EMA 20 (blue) and the EMA 100 (dashed pink). Labels on the four closed trades with the result in dollars per ounce.

WhenWhatPrice
29 Jan 2026 00:00 UTCEMA 205,214.89 → 4,954.21
29 Jan 2026 00:00 UTCEMA 1004,883.97 → 4,922.21
2 Feb 2026 04:00 UTClong closed: +123 $4,588.94
4 Feb 2026 08:00 UTCshort closed: −462 $5,050.14
5 Feb 2026 12:00 UTClong closed: −231 $4,819.55
7 Feb 2026 08:00 UTCshort closed: −146 $4,965.35

Times in UTC.

The peak and its neighborhood

A good parameter lives in an area: if 15/40 works, 12/40, 15/30 and 20/50 should work more or less too. The neighbors of the best pair (the eight pairs next to it in the grid) give +670 $ on average, from +433 to +813. The best earns twice its neighbors. That marks an isolated peak: part of the result depends on the exact dates the two averages crossed, and a nearby value would have moved them.

Whoever picks 15/40 takes home the part that depends on chance and cannot count on it for the future. A value with similar neighbors (a plateau) says more.

What the best of 54 is worth

You can measure it. Take the returns of the H4 candles and shuffle them in blocks of six candles (one day): the resulting prices have the same returns and the same volatility, but the order of the days is random and the long trends disappear. Repeat the same grid of 54 pairs on 300 of these synthetic prices.

On shuffled prices (300 trials)Median5th to 95th percentile
Total of the best among 54 pairs+975 $from −614 to +2,566 $
Median total among the 54 pairs−14 $from −1,590 to +1,461 $
Total of the 20/50 pair−175 $from −1,964 to +1,679 $

On shuffled prices, the best of 54 pairs earns +975 $ in the median. The observed figure, +1,336 $, is beaten by 35% of the trials: chance does at least as well once in three. The observed median of the pairs, +543 $, is beaten in 29% of the trials; positive pairs are 44 out of 54, while on shuffled prices the median is 26 out of 54. The real data sits above the median of the shuffled ones but inside the interval: with ten months of one instrument you cannot say the averages have an edge.

The maximum grows with the number of tries, even when no edge exists. Same 300 trials, median of the best among the first k pairs (the 20/50 first):

Pairs triedBest on shuffled prices (median)Best observed
1 (the 20/50)−175 $+433 $
4+200 $+752 $
16+779 $+1,100 $
54+975 $+1,336 $

With one pair, chosen beforehand, shuffled prices give −175 $ in the median. With 54 pairs tried and the best kept, +975 $: the apparent edge of an optimized parameter is also the price of the number of tries. In every row the observed result stays inside the interval of the shuffled prices.

A test on new data

The simplest check uses the data themselves: choose the parameter on one part of the period and measure it on the other. The period is split in half (11 May 2026).

  • Choose in the first half, test in the second. In the first half the best pair is 15/40 (10 trades, +1,365 $). In the second half the same pair makes 18 trades for +97 $, while the median of all pairs in the second half is +144 $ (46 positive pairs out of 54). The winner of the first half did less than the middle pair.
  • Choose in the second half, test in the first. The best is 5/20 (48 trades, +630 $). In the first half it makes 41 trades for +529 $, with the median of all pairs at +463 $ (42 positive out of 54). Here the winner stays above the median, by a little.

One case in two held, and in the other the choice added nothing compared with a random pair. Figure 3 shows the whole period: the 15/40 is at +1,318 $ at mid-period and adds 181 $ in the second half (+1,499 $ with the open position valued at the last close; in the half-split test the system restarts from zero, which is why +97 $). The 20/100 goes from −1,146 to −952 $.

Figure 3. Result over time of the two systems across the whole period (daily candles): the 15/40 is at +1,318 $ on 11 May and +1,499 $ at the end; the 20/100 goes from −1,146 to −952 $.Data: gold, XAUUSDT perpetual future (real candles) · daily (D1) · from 15 Dec 2025 to 5 Oct 2026.
Read the chart in words

Daily gold chart from December 2025 to October 2026, split in two halves (first half: where you choose, second half: the test), with below the result in dollars per ounce of the EMA 15/40 (black) and the EMA 20/100 (dashed pink).

WhenWhatPrice
15 Dec 2025 → 12 May 2026first half: where you choose
12 May 2026 → 5 Oct 2026second half: the test

Times in UTC.

How to optimize with more care

  1. Decide the values before looking at results (the standard ones are fine) and write them down. Every extra value tried moves the "best".
  2. If you try a grid, keep the whole table and count the variants: reading the best without knowing how many it was picked from tells you nothing.
  3. Look for a plateau: take a value seriously when its neighbors earn about the same.
  4. Choose on one part of the data, test on the other, and compare with shuffled prices.

Exercises

Chapter exercises

1. On the chart (EMA 20/100, H4) the letters sit on the four trades closed between 2 and 7 February 2026. Which letter is the trade with the largest loss?

Chart exercise. Data: gold, XAUUSDT perpetual future (real candles) · 4 hours (H4) · from 29 Jan 2026 00:00 UTC to 8 Feb 2026 20:00 UTC.
Read the chart in words
WhenWhatPrice
2 Feb 2026 04:00 UTCPoint A4,588.94
4 Feb 2026 08:00 UTCPoint B5,050.14
5 Feb 2026 12:00 UTCPoint C4,819.55
7 Feb 2026 08:00 UTCPoint D4,965.35

Times in UTC.

2. The 15/40 pair earned +1,336 $, and the eight neighboring pairs +670 $ on average (from +433 to +813). What is it sensible to conclude?

3. On prices with the same returns, in random order, the best of 54 pairs of averages makes +975 $ in the median. What does it say about the observed +1,336 $?

4. You choose the best pair on the first half of the data (+1,365 $ in 10 trades) and test it on the second: +97 $, with the median of all pairs at +144 $. What happened?

Have a question or want to share your exercise?

Post in the community, or join the free signals room on Telegram.

Educational content, not financial advice. Trading involves risk.