1

I'm trying to figure out how ADX is calculated in MetaTrader. I have studied the documentation and ADX.mq4 code but am still getting some wrong results.

I'm experimenting with monthly data to see the calculation from the first bars of history. Using the standard 14 period and Closed applied price.

The indicator starts drawing on the chart from the 15th bar, but the data window shows values yet from the second bar which is ok, since it uses the exponential method.

Assume we have the following OHLC bar data:

2002.06.01,00:00,0.93240,0.99140,0.93240,0.99100
2002.07.01,00:00,0.99100,1.01180,0.97260,0.97730

Then the first value (starting from the second bar) should be calculated as follows:

1. price move
+M = High(i) - High(i - 1)  =>  0.0204
-M = Low(i - 1) - Low(i)    =>  -0.0402

2. directional move and true range
+DM = if +M > -M and +M > 0 then +M else 0  =>  0.0204
-DM = if -M > +M and -M > 0 then -M else 0  =>  0
TR = Max((High - Low), Abs(High - Close(i - 1)), Abs(Low - Close(i - 1)))   =>  0.0392

3. the first exponential value of directional movement index
+DI = +DM / TR * 100        =>  52.0408
-DI = -DM / TR * 100        =>  0

4. the first exponential value of average directional movement index
ADX = Abs(+DI - -DI) / (+DI + -DI) * 100    =>  100

But the terminal displays the following:

+DI = 6.9388
-DI = 0
ADX = 13.3333

What is wrong with the manual calculations?

PS: the same results are observed in MT5

yaugenka
  • 2,602
  • 2
  • 22
  • 41

0 Answers0