MACD settings: what 12, 26 and 9 mean and what changes
By Oalgo · Last reviewed
MACD has three settings: the fast length, the slow length and the length of the average line. Oalgo's builder starts at 12, 26 and 9. A faster pair makes the MACD line react sooner and swing wider. A shorter average length makes the average line follow the MACD line closely, so the histogram is smaller.
What does each MACD setting do?
#| Setting | Starts at in the builder | What it is | What a shorter value does |
|---|---|---|---|
| Fast length | 12 | The length of the faster EMA of the close | The fast EMA follows price more closely, so the gap to the slow EMA gets larger |
| Slow length | 26 | The length of the slower EMA of the close | The slow EMA follows price more closely, so the gap to the fast EMA gets smaller |
| Average length | 9 | The length of the EMA of the MACD line, which is the average line | The average line stays closer to the MACD line, so the histogram gets smaller |
The MACD line is the fast EMA minus the slow EMA, so what matters most is the distance between the two lengths, not each length alone.
What does a different setting change?
#The table uses the 120 candles of the example prices and counts from candle 40 on, so every setting is past its start. The EMAs start from the first close, so the first stretch of every MACD line is shaped by where they start. A crossing here is a candle where the MACD line moves from one side of the average line to the other.
| Fast, slow, average | MACD line, lowest to highest | Histogram, lowest to highest | Crossings, candles 40 to 120 |
|---|---|---|---|
| 12, 26, 9 (the builder's start) | −3.79 to 4.71 | −2.38 to 2.52 | 7 |
| 8, 26, 9 | −6.19 to 7.28 | −3.69 to 3.81 | 6 |
| 19, 26, 9 | −1.43 to 1.74 | −0.93 to 0.98 | 5 |
| 12, 17, 9 | −2.04 to 2.37 | −1.15 to 1.19 | 2 |
| 12, 39, 9 | −4.95 to 6.05 | −3.26 to 3.49 | 11 |
| 12, 26, 5 | −3.79 to 4.71 | −1.46 to 1.48 | 6 |
| 12, 26, 14 | −3.79 to 4.71 | −3.22 to 3.36 | 5 |
| 8, 17, 9 | −4.50 to 5.05 | −2.48 to 2.48 | 4 |
| 19, 39, 9 | −3.27 to 3.89 | −1.90 to 1.99 | 3 |
- Moving the fast length towards the slow one shrinks the MACD line: with fast 19 it stays between −1.43 and 1.74, with fast 8 it reaches −6.19 and 7.28.
- A longer slow length widens it: slow 39 reaches −4.95 and 6.05, slow 17 stays between −2.04 and 2.37.
- The average length leaves the MACD line as it is and changes only the average line and the histogram: the histogram spans about ±1.5 with 5, ±2.5 with 9 and ±3.3 with 14.
- The number of crossings does not rise or fall in one direction with every setting. The average length gave 6, 7 and 5 crossings for 5, 9 and 14.
Does a faster setting turn sooner?
#On these prices, yes. The table shows two turns on the same prices: the first candle after candle 60 where the MACD line fell below the average line, and the last candle where it rose above it (the one still in place on candle 120). Sooner is not better or worse. It only means the line reacted earlier.
| Fast, slow, average | First fall below the average line after candle 60 | Last rise above the average line |
|---|---|---|
| 8, 17, 9 | Candle 68 | Candle 97 |
| 12, 26, 9 | Candle 71 | Candle 100 |
| 19, 39, 9 | Candle 83 | Candle 111 |
How do people use MACD settings in rules?
#- Keep 12, 26 and 9 and change one setting at a time, testing each version on past prices.
- A faster pair, such as 8 and 17, so the MACD line turns earlier.
- A slower pair, such as 19 and 39, so the line turns later.
- A rule on the histogram instead of the lines, since the histogram is the gap between the MACD line and the average line.
What can MACD settings not tell you?
#No setting predicts price, and a faster line can turn on a move that does not last. Trying many settings until one looks good is how a rule becomes overfitted. Test on more than one date range with a backtest and change one thing at a time.
In Oalgo you can tell Oalgo AI your MACD rule, with the three lengths you want, in your own words, check the rule it builds, and test it. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue. A rule can read the MACD line, the average line or the histogram.
Read next
- MACD indicator explained: how to read itThe MACD indicator is the gap between a fast and a slow moving average. See how it is calculated, how to read the lines and histogram, and how to test it.
- MACD crossover strategy: rules and how to test itA MACD crossover enters when the MACD line crosses above its average line and exits on the cross back. See the rules, how to test them, and what they miss.