technicalindicators icon indicating copy to clipboard operation
technicalindicators copied to clipboard

is ADX correct (difference with TradingView)

Open enriquepiatti opened this issue 3 years ago • 2 comments

I'm comparing the results from TradingView charts (with ADX built in indicator), same input period, same candles (this is ok because the SMA for example is returning same values in TradingView and with technicalindicators), but the result for ADX is not the same!
Does somebody know why is that?
Do you know some other chart with ADX indicator to compare with a 3rd reference?

This is the code used by TradingView (in PineScript):

up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / truerange)
minus = fixnan(100 * rma(minusDM, len) / truerange)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

rma = Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.

enriquepiatti avatar Aug 28 '21 13:08 enriquepiatti

see my comment here https://github.com/anandanand84/technicalindicators/issues/239, might work for you as well

marcusmota avatar Aug 30 '21 20:08 marcusmota

I used the following page to develop my custom ADX indicator: https://school.stockcharts.com/doku.php?id=technical_indicators:average_directional_index_adx

Also, you can pull up a chart with the ADX indicator for free on any stock. Good luck!

jere-0 avatar Sep 12 '21 05:09 jere-0