Skip to content

Majority Rule ​

Share of bars that closed up over the last N, in percent.

Kind indicator · Drawn in its own pane

Try it ​

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

Inputs ​

InputTypeDefault
Lengthint10
Colorcolor"#2962FF"

Source ​

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

js
indicator({ name: "Majority Rule", shortTitle: "MR", overlay: false, precision: 2 });
const length = input.int("Length", 10, { min: 1 });
const up = ta.calc([ta.change(candle.close, 1)], (d) => (d > 0 ? 1 : d === d ? 0 : NaN));
plot(ta.calc([ta.sum(up, length)], (s) => (s / length) * 100), { title: "Majority Rule", color: input.color("Color", "#2962FF", { group: "Style" }) });
hline(50, { title: "50", color: "#787B86", style: "dashed" });

AlphaScript language v0.1 · runtime 0.2.0