Skip to content

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 ​

InputTypeDefault
ADX smoothingint14
DI lengthint14
ADX colorcolor"#F50057"
+DI colorcolor"#2962FF"
-DI colorcolor"#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" }) });

AlphaScript language v0.1 · runtime 0.2.0