ADX

Calculates the Average Directional Index indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
periodNumber14-

Returns: Series<Number>

ADX is a built-in function - you can use it directly. Below is an example implementation:

1 function ADX(period = 14):
2 plusDI = DirectionalMovement.Positive(period)
3 minusDI = DirectionalMovement.Negative(period)
4 dx = (Math.Abs(plusDI - minusDI) / Math.Abs(plusDI + minusDI)) * 100 if plusDI != minusDI else 0
5
6 SMA(dx, period)