Skip to content

Ulcer Index ​

Depth and duration of drawdowns from the N-bar high.

Kind indicator · Drawn in its own pane

Try it ​

On the chart, press / and choose Ulcer Index under Oscillators. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
Lengthint14
Sourcesource"close"
Colorcolor"#2962FF"

Source ​

From packages/alphascript/indicators/ulcer.as.js.

js
indicator({ name: "Ulcer Index", shortTitle: "Ulcer", overlay: false, precision: 2 });
const length = input.int("Length", 14, { min: 1 });
const src = input.source("Source", "close");
const dd = ta.calc([src, ta.highest(src, length)], (x, h) => (100 * (x - h)) / h);
plot(ta.calc([ta.sma(ta.calc([dd], (d) => d * d), length)], (v) => math.sqrt(v)), { title: "Ulcer Index", color: input.color("Color", "#2962FF", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0