Skip to content

Historical Volatility ​

Annualised standard deviation of log returns, in percent.

Kind indicator · Drawn in its own pane

Try it ​

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

Inputs ​

InputTypeDefault
Lengthint10
Periods per yearint365
Colorcolor"#2962FF"

Source ​

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

js
indicator({ name: "Historical Volatility", shortTitle: "HV", overlay: false, precision: 2 });
const length = input.int("Length", 10, { min: 2 });
const annual = input.int("Periods per year", 365, { min: 1 });
const lr = ta.calc([candle.close], (c) => math.log(c / candle.close.at(1)));
plot(ta.calc([ta.stdev(lr, length)], (s) => 100 * s * math.sqrt(annual)), { title: "HV", color: input.color("Color", "#2962FF", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0