Appearance
Directional Movement Index
+DI and -DI directional movement with ADX trend strength.
Kind indicator · Drawn in its own pane
Try it
On the chart, press / and choose Directional Movement Index under Trend. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| ADX smoothing | int | 14 |
| DI length | int | 14 |
| ADX color | color | "#F50057" |
| +DI color | color | "#2962FF" |
| -DI color | color | "#FF6D00" |
Source
From packages/alphascript/indicators/dmi.as.js.
js
indicator({ name: "Directional Movement Index", shortTitle: "DMI", overlay: false, precision: 2 });
const smoothing = input.int("ADX smoothing", 14, { min: 1, max: 50 }), diLength = input.int("DI length", 14, { min: 1 });
const d = ta.dmi(diLength, smoothing);
plot(d.adx, { title: "ADX", color: input.color("ADX color", "#F50057", { group: "Style" }) });
plot(d.plus, { title: "+DI", color: input.color("+DI color", "#2962FF", { group: "Style" }) });
plot(d.minus, { title: "-DI", color: input.color("-DI color", "#FF6D00", { group: "Style" }) });