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.

Chart: example prices, then below them the MACD line for three pairs of lengths on the same scale: 8 and 17, 12 and 26, and 19 and 39, with a line at zero. The 8 and 17 line swings the widest.PriceMACD 8, 17MACD 12, 26MACD 19, 390
Example prices, made up for this page. The average length is 9 in all three.

What does each MACD setting do?

#
SettingStarts at in the builderWhat it isWhat a shorter value does
Fast length12The length of the faster EMA of the closeThe fast EMA follows price more closely, so the gap to the slow EMA gets larger
Slow length26The length of the slower EMA of the closeThe slow EMA follows price more closely, so the gap to the fast EMA gets smaller
Average length9The length of the EMA of the MACD line, which is the average lineThe 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, averageMACD line, lowest to highestHistogram, lowest to highestCrossings, candles 40 to 120
12, 26, 9 (the builder's start)−3.79 to 4.71−2.38 to 2.527
8, 26, 9−6.19 to 7.28−3.69 to 3.816
19, 26, 9−1.43 to 1.74−0.93 to 0.985
12, 17, 9−2.04 to 2.37−1.15 to 1.192
12, 39, 9−4.95 to 6.05−3.26 to 3.4911
12, 26, 5−3.79 to 4.71−1.46 to 1.486
12, 26, 14−3.79 to 4.71−3.22 to 3.365
8, 17, 9−4.50 to 5.05−2.48 to 2.484
19, 39, 9−3.27 to 3.89−1.90 to 1.993
  • 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, averageFirst fall below the average line after candle 60Last rise above the average line
8, 17, 9Candle 68Candle 97
12, 26, 9Candle 71Candle 100
19, 39, 9Candle 83Candle 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