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:
| Pair | Trades | Total | |
|---|---|---|---|
| Best | 15/40 | 30 | +1,336 $ |
| 5/20 | 92 | +1,127 $ | |
| 5/30 | 68 | +1,100 $ | |
| 5/26 | 76 | +1,053 $ | |
| 8/20 | 68 | +980 $ | |
| Worst | 30/60 | 28 | −430 $ |
| 25/100 | 23 | −489 $ | |
| 15/100 | 27 | −554 $ | |
| 30/100 | 23 | −641 $ | |
| 20/100 | 29 | −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):
| Fast | Slow 30 | Slow 40 | Slow 50 | Slow 80 | Slow 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.
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.
| When | What | Price |
|---|---|---|
| 29 Jan 2026 00:00 UTC | EMA 15 | 5,259.61 → 4,963.56 |
| 29 Jan 2026 00:00 UTC | EMA 40 | 5,092.41 → 4,942.81 |
| 31 Jan 2026 04:00 UTC | long closed: +464 $ | 4,906.48 |
| 7 Feb 2026 12:00 UTC | short closed: −59 $ | 4,965.58 |
Times in 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.
| When | What | Price |
|---|---|---|
| 29 Jan 2026 00:00 UTC | EMA 20 | 5,214.89 → 4,954.21 |
| 29 Jan 2026 00:00 UTC | EMA 100 | 4,883.97 → 4,922.21 |
| 2 Feb 2026 04:00 UTC | long closed: +123 $ | 4,588.94 |
| 4 Feb 2026 08:00 UTC | short closed: −462 $ | 5,050.14 |
| 5 Feb 2026 12:00 UTC | long closed: −231 $ | 4,819.55 |
| 7 Feb 2026 08:00 UTC | short 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) | Median | 5th 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 tried | Best 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 $.
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).
| When | What | Price |
|---|---|---|
| 15 Dec 2025 → 12 May 2026 | first half: where you choose | |
| 12 May 2026 → 5 Oct 2026 | second half: the test |
Times in UTC.
How to optimize with more care
- Decide the values before looking at results (the standard ones are fine) and write them down. Every extra value tried moves the "best".
- 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.
- Look for a plateau: take a value seriously when its neighbors earn about the same.
- 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?
Read the chart in words
| When | What | Price |
|---|---|---|
| 2 Feb 2026 04:00 UTC | Point A | 4,588.94 |
| 4 Feb 2026 08:00 UTC | Point B | 5,050.14 |
| 5 Feb 2026 12:00 UTC | Point C | 4,819.55 |
| 7 Feb 2026 08:00 UTC | Point D | 4,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.