Skip to content

Williams Fractals ​

Marks highs and lows that stand above or below their neighbours.

Kind indicator · Drawn on the price pane

Try it ​

On the chart, press / and choose Williams Fractals under Support & resistance. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
Periodsint2
Up fractal colorcolor"#089981"
Down fractal colorcolor"#F23645"

Source ​

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

js
indicator({ name: "Williams Fractals", shortTitle: "Fractals", overlay: true });
const n = input.int("Periods", 2, { min: 2, max: 50 });
const up = ta.calc([ta.pivothigh(n, n)], (v) => (v === v ? 1 : 0)), down = ta.calc([ta.pivotlow(n, n)], (v) => (v === v ? 1 : 0));
plotShape(up, { shape: "triangleDown", location: "aboveBar", offset: -n, color: input.color("Up fractal color", "#089981", { group: "Style" }) });
plotShape(down, { shape: "triangleUp", location: "belowBar", offset: -n, color: input.color("Down fractal color", "#F23645", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0