DirectionalMovement.Positive

Calculates the Positive line of the Directional Movement indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
periodNumber14-

Returns: Series<Number>

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

1 function DirectionalMovement.Positive(period = 14):
2 highDelta = high - high[1]
3 lowDelta = low[1] - low
4
5 dmPlus = highDelta if (highDelta > lowDelta and highDelta > 0) else 0
6 trueRange = Math.Max(high, close[1]) - Math.Min(low, close[1])
7
8 SMA(dmPlus * 100 / Math.Max(trueRange, 0.00001), period)