ta.dmi
Measure trend direction and strength with directional indicators and their average.
ta.dmi(diLength, adxSmoothing, bars)Directional Movement: [positive indicator, negative indicator, average directional index]. The positive move is high - high[1] when that move exceeds both low[1] - low and zero, else 0. The negative move mirrors it. Each is smoothed with Wilder's moving average over diLength, divided by the same smoothing of ta.tr and scaled by 100. The average directional index is Wilder's moving average over adxSmoothing of 100*abs(plus - minus)/(plus + minus), taken as 0 when both are 0. Bars are read from bars.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Unit | Default | Range | Description |
|---|---|---|---|---|---|---|
diLength | Constant | number | - | 14 | 1 to 10000 | Window for the directional movement and the true range. |
adxSmoothing | Constant | number | - | 14 | 1 to 10000 | Window the directional index is smoothed over. |
bars | Constant | bars | bars | na | - | Which bars to read: a declared series, or na for the chart's own. |
Outputs
| Name | Type | Unit |
|---|---|---|
diplus | number | - |
diminus | number | - |
adx | number | - |
The outputs come back in this order: [diplus, diminus, adx] = ta.dmi(…).
Warm-up and missing values
- Warm-up
diLength + adxSmoothingbars. Names in the warm-up are this operator’s parameters.- Missing values
- The two indicators are na until the directional movement and the true range have both warmed up over
diLength. The average directional index is na until its own smoothing has warmed up on top of that. na when the smoothed true range is zero.
Example
[diPlus, diMinus, adx] = ta.dmi(14, 14)[diPlus, diMinus, adx] = ta.dmi(14, 14)
plot(adx, "Trend strength")