The calculation consists of several stages:
The absolute positive (+M) and negative (-M) price movement is calculated - the difference between the highs and lows of the price of the current and previous calculation period.
+DM and -DM are calculated, which, depending on the conditions laid down in the algorithm, can take on the value +M, -M or 0.
Positive (+DI) and negative (-DI) directional movement is calculated - separate Wilder indicators. Formula: EMA from the ratio of +DM and -DM to the true range (TR).
ADX is calculated: 100*EMA(+DI - -DI/+DI + -DI)