Appearance
52 Week High/Low
Highest high and lowest low of the last 52 weeks.
Kind indicator · Drawn on the price pane
Try it
On the chart, press / and choose 52 Week High/Low under Support & resistance. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| High color | color | "#089981" |
| Low color | color | "#F23645" |
Source
From packages/alphascript/indicators/highlow52.as.js.
js
indicator({ name: "52 Week High/Low", shortTitle: "52W H/L", overlay: true });
/** @param {SecurityContext} w @param {1 | -1} sign */
const extreme = (w, sign) => w.ta.calc([w.candle.high, w.candle.low], () => {
let m = NaN;
for (let k = 0; k < 52; k++) {
const v = sign > 0 ? w.candle.high.at(k) : w.candle.low.at(k);
if (v !== v) break;
if (m !== m || sign * (v - m) > 0) m = v;
}
return m;
});
plot(request.security("1W", (w) => extreme(w, 1)), { title: "52W High", style: "step", color: input.color("High color", "#089981", { group: "Style" }) });
plot(request.security("1W", (w) => extreme(w, -1)), { title: "52W Low", style: "step", color: input.color("Low color", "#F23645", { group: "Style" }) });