MyAlgoMate
// INDICATOR FORMULA

ADX formula: how to calculate ADX, +DI and −DI (with Excel)

How the Average Directional Index is worked out — directional movement, +DI and −DI, DX and Wilder's 14-period ADX, column by column. With a worked example, the Excel formulas, a free Excel sheet and a box to calculate ADX from your own high, low and close.

Last updated:

Download the free ADX Excel sheet (.xlsx)

Needs: high, low, close · Standard settings: Period 14

The ADX formula

Up-move   = High − previous High
Down-move = previous Low − Low
+DM = Up-move,   if Up-move > Down-move and Up-move > 0   (otherwise 0)
−DM = Down-move, if Down-move > Up-move and Down-move > 0 (otherwise 0)
TR  = true range (see the ATR formula)

TR (14), +DM (14), −DM (14):
    first value = sum of the first 14 values
    next value  = previous − previous ÷ 14 + current value

+DI = 100 × +DM (14) ÷ TR (14)
−DI = 100 × −DM (14) ÷ TR (14)
DX  = 100 × |+DI − −DI| ÷ (+DI + −DI)
ADX = average of the first 14 DX values, then
      (previous ADX × 13 + DX) ÷ 14

This is Wilder's original method from 1978. Smoothing with running sums or with averages gives the same +DI and −DI, because both the top and the bottom of each fraction change in the same way. The true range is worked out as on the ATR formula page.

How to calculate ADX step by step

  1. Work out the true range, +DM and −DM from the second candle. Day 2: the high fell (up-move 1,004.60 − 1,010.00 is below zero) and the low fell by 2.85, so +DM = 0.00, −DM = 2.85 and the true range is 16.85.
  2. Add up the first 14 of each. Day 2 to Day 15 gives, on Day 15: TR (14) 302.35, +DM (14) 99.00, −DM (14) 29.55.
  3. Turn them into +DI, −DI and DX. +DI = 100 × 99.00 ÷ 302.35 = 32.74; −DI = 100 × 29.55 ÷ 302.35 = 9.77; DX = 100 × |32.74 − 9.77| ÷ (32.74 + 9.77) = 54.03.
  4. Smooth the three totals from the next candle on. Day 16: TR (14) = 302.35 − 302.35 ÷ 14 + 41.45 = 322.20, and the same for +DM and −DM.
  5. Average DX for ADX. The first ADX, on Day 28, is the average of the 14 DX values from Day 15 to Day 28: 27.06. Day 29: (27.06 × 13 + 52.31) ÷ 14 = 28.86.
  6. Repeat for every candle. On Day 60 the example's ADX is 28.68, +DI 38.55 and −DI 15.06.

Worked example — and calculate ADX from your own prices

The table works through 60 daily candles of an imaginary stock, column by column — the same columns as the Excel sheet. To calculate ADX for your own stock, clear the box and paste your high, low, close from Excel or your broker's download.

One row per candle, oldest first. Paste straight from Excel or your broker's download; a date or time column becomes the row label. Filled with our example prices.

Latest values

ADX (14): 28.6780+DI: 38.5515−DI: 15.0552
ADX calculated from the example prices
DayHighLowCloseTrue range+DM−DMTR (14)+DM (14)−DM (14)+DI−DIDXADX (14)
Day 11,010.00990.601,001.15
Day 21,004.60987.75987.9516.850.002.85
Day 31,011.50986.001,009.1525.506.900.00
Day 41,015.001,001.851,012.6013.153.500.00
Day 51,012.00990.80993.2521.800.0011.05
Day 61,012.60990.901,008.6021.700.600.00
Day 71,018.951,003.801,013.6015.156.350.00
Day 81,012.95994.751,001.5518.850.009.05
Day 91,033.25995.301,031.5537.9520.300.00
Day 101,046.151,028.501,040.0517.6512.900.00
Day 111,041.801,027.701,033.1514.100.000.80
Day 121,065.801,031.151,064.8034.6524.000.00
Day 131,086.001,056.851,083.5529.1520.200.00
Day 141,090.251,067.251,067.9523.004.250.00
Day 151,074.301,061.451,063.5012.850.005.80302.350099.000029.550032.74359.773454.0257
Day 161,067.351,025.901,030.2041.450.0035.55322.203691.928662.989328.531219.549518.6804
Day 171,033.001,011.751,012.2021.250.0014.15320.439085.362272.640126.639222.66898.0519
Day 181,019.90979.85981.6040.050.0031.90337.600579.264999.351523.478929.428711.2456
Day 19988.30969.40970.5518.900.0010.45332.386273.6032102.704922.143930.899316.5062
Day 20973.10959.05960.9014.050.0010.35322.694368.3458105.718921.179732.761321.4708
Day 21980.35958.30978.3022.057.250.00321.694770.713998.167521.981730.515716.2561
Day 22981.50957.00958.8524.500.001.30323.216565.663092.455620.315528.604816.9446
Day 23963.00942.60946.7520.400.0014.40320.529660.9727100.251619.022531.276924.3629
Day 24957.70931.65937.9526.050.0010.95323.684756.6175104.040817.491632.142629.5181
Day 25945.75926.05927.8519.700.005.60320.264352.5734102.209316.415631.914032.0681
Day 26924.60910.25911.2017.600.0015.80314.988348.8182110.708615.498435.146938.7963
Day 27919.05900.00905.1519.050.0010.25311.539145.3312113.050914.550736.287942.7572
Day 28904.50884.70885.9520.450.0015.30309.736442.0932120.275813.590038.831748.151227.0596
Day 29891.25871.55874.7019.700.0013.15307.312339.0866124.834712.718840.621452.310528.8633
Day 30880.70849.70855.8031.000.0021.85316.361436.2947137.767911.472543.547658.297030.9657
Day 31868.95858.15862.1513.150.000.00306.914233.7022127.927310.981041.681858.297032.9179
Day 32875.05859.50866.4515.556.100.00300.541837.3949118.789712.442539.525252.114534.2891
Day 33870.55843.00845.1027.550.0016.50306.624534.7238126.804711.324541.355057.005935.9117
Day 34854.70846.55851.559.600.000.00294.322732.2436117.747210.955240.006257.005937.4185
Day 35863.70847.85860.2015.859.000.00289.149738.9405109.336713.467237.813247.476138.1369
Day 36862.95845.40854.8017.550.002.45286.046136.1590103.976912.641036.349748.394438.8695
Day 37882.25858.05877.2027.4519.300.00293.064352.876296.550018.042532.945029.227738.1808
Day 38893.65868.85888.4524.8011.400.00296.931160.499389.653620.374930.193419.416436.8405
Day 39908.35889.60905.4019.9014.700.00295.621770.878083.249823.975928.16098.027034.7824
Day 40913.10895.65896.8017.454.750.00291.955970.565277.303324.169826.47774.556832.6234
Day 41894.65887.85889.608.950.007.80280.051965.524979.581723.397428.41689.687230.9851
Day 42898.55884.80895.3013.753.900.00273.798264.744573.897323.646826.98976.601729.2435
Day 43920.60889.25919.0031.3522.050.00285.591282.169968.618928.771924.02708.986827.7966
Day 44920.60916.30918.354.300.000.00269.491876.300663.717528.312823.64368.986826.4530
Day 45919.30903.80906.2515.500.0012.50265.742470.850671.666326.661426.96830.572424.6044
Day 46937.35900.30932.1037.0518.050.00283.810883.839866.547329.540723.447811.498723.6683
Day 47947.15930.20944.3516.959.800.00280.488687.651361.793931.249522.030817.302223.2135
Day 48949.20937.25948.7011.952.050.00272.403783.440557.380030.631221.064318.506122.8773
Day 49971.15949.05966.3522.4521.950.00275.396399.430453.281536.104519.347230.219623.4018
Day 50965.90954.75955.6011.600.000.00267.325192.328349.475734.537818.507730.219623.8887
Day 51971.35954.15969.1017.205.450.00265.430591.183445.941734.353017.308432.993024.5391
Day 52997.00966.55984.3530.4525.650.00276.9212110.320342.660139.838215.405244.228025.9454
Day 53992.30980.25980.9012.050.000.00269.1911102.440339.613038.054914.715644.228027.2513
Day 54984.70961.40962.5023.300.0018.85273.263195.123155.633534.810120.358926.194327.1758
Day 55964.60953.00960.2011.600.008.40265.344388.328660.059733.288322.634619.050726.5954
Day 56969.05954.50967.3514.554.450.00260.941286.469455.769733.137521.372521.583226.2374
Day 57982.20960.60971.0021.6013.150.00263.902593.443051.786135.408219.623228.683626.4121
Day 58987.10967.55981.7519.554.900.00264.602391.668548.087134.643918.173431.184026.7530
Day 59999.95979.00994.8520.9512.850.00266.652297.970844.652336.741016.745537.384227.5124
Day 601,015.15987.351,012.3527.8015.200.00275.4056106.172941.462938.551515.055243.830828.6780
Everything is worked out in your browser. Nothing you paste is stored or sent.

The example prices are made up for this page — they are not real market data. ADX is a calculation from past prices, not a forecast, a signal or advice to buy or sell. MyAlgoMate provides trading technology, not investment advice.

How to calculate ADX in Excel

Put the headings in row 1 and the first candle in row 2, oldest at the top. Then type these formulas — each column uses the ones to its left:

  1. A

    Day

    A2 downwards: your dates, oldest at the top.

  2. B

    High

    B2 downwards: the high prices, oldest at the top.

  3. C

    Low

    C2 downwards: the low prices, oldest at the top.

  4. D

    Close

    D2 downwards: the closing prices, oldest at the top.

  5. E

    True range

    E3 =MAX(B3-C3,ABS(B3-D2),ABS(C3-D2)) — then copy it down to the last row.

  6. F

    +DM

    F3 =IF(AND(B3-B2>C2-C3,B3-B2>0),B3-B2,0) — then copy it down to the last row.

  7. G

    -DM

    G3 =IF(AND(C2-C3>B3-B2,C2-C3>0),C2-C3,0) — then copy it down to the last row.

  8. H

    TR (14)

    H16 =SUM(E3:E16) — this cell only (the starting value).

    H17 =H16-H16/14+E17 — then copy it down to the last row.

  9. I

    +DM (14)

    I16 =SUM(F3:F16) — this cell only (the starting value).

    I17 =I16-I16/14+F17 — then copy it down to the last row.

  10. J

    -DM (14)

    J16 =SUM(G3:G16) — this cell only (the starting value).

    J17 =J16-J16/14+G17 — then copy it down to the last row.

  11. K

    +DI

    K16 =100*I16/H16 — then copy it down to the last row.

  12. L

    -DI

    L16 =100*J16/H16 — then copy it down to the last row.

  13. M

    DX

    M16 =IF(K16+L16=0,0,100*ABS(K16-L16)/(K16+L16)) — then copy it down to the last row.

  14. N

    ADX (14)

    N29 =AVERAGE(M16:M29) — this cell only (the starting value).

    N30 =(N29*13+M30)/14 — then copy it down to the last row.

Row 2 (the first candle) has no previous high or low, so the calculation starts in row 3; ADX starts in row 29.

Prefer not to type them? The free sheet has every formula filled in for the example prices — replace the prices with yours and extend the rows. It opens in Microsoft Excel (we checked every value against the table above), and you can import it into Google Sheets or LibreOffice.

Download the free ADX Excel sheet (.xlsx)

What the lines show

+DI and −DI compare the size of recent up-moves and down-moves with the true range. DX and ADX measure how far apart +DI and −DI are — so ADX says how one-sided recent movement has been, not which side. Many charts draw a reference line at 20 or 25. All of it is calculated from past prices; it is not a forecast or advice.

// FAQ

ADX calculation — questions, answered.

Work out +DM, −DM and the true range for each candle; smooth each over 14 candles with Wilder's method; divide to get +DI and −DI; turn their gap into DX = 100 × |+DI − −DI| ÷ (+DI + −DI); and finally ADX = the 14-period Wilder average of DX.

High, low and close in columns B, C and D from row 2. From row 3: true range, +DM and −DM (formulas on this page). In row 16, SUM the first 14 of each; from row 17, previous − previous ÷ 14 + current. +DI and −DI = 100 × the smoothed DM ÷ the smoothed true range, then DX. ADX in row 29 = AVERAGE of the first 14 DX values, then (previous × 13 + DX) ÷ 14. The free sheet has every formula filled in.

Up-move = High − previous High; down-move = previous Low − Low. +DM is the up-move if it is larger than the down-move and above zero, otherwise 0. −DM is the down-move if it is larger than the up-move and above zero, otherwise 0. So on any candle at most one of them is above zero.

Directional movement starts on the 2nd candle, the 14-candle sums are ready on the 15th, and ADX is a 14-period average of DX, so the first ADX (14) appears on the 28th candle. Because of the smoothing, use many more candles than that if you want to match a chart.

DMI (the Directional Movement Index) is the set of +DI and −DI lines. DX measures how far apart they are on a 0–100 scale. ADX is the smoothed average of DX. Many charts show all three lines in one 'ADX/DMI' indicator.

Mostly the starting point: ADX is smoothed twice, so it takes a long history to settle — start from 150 or more candles. Some charts let you set a different smoothing length for ADX and for the DI lines. Spot vs futures prices and the timeframe matter too.

More indicator formulas, with Excel sheets

Turn your own rules into automated orders.

Already use ADX in your own rules? MyAlgoMate's algo trading software places the orders your rules call for at 150+ Indian brokers — and TradeBridge turns your own TradingView or Chartink alerts into live orders. You decide the rules; we provide the technology.

Share this page