ta.realizedvol
Measure annualised volatility from the spread of recent log returns.
ta.realizedvol(source, length, periodsPerYear)Annualised realised volatility: ta.stdev(ta.logret(source, 1), length) * sqrt(periodsPerYear), the population standard deviation of one-bar log returns, with no mean subtracted beyond the window's own. periodsPerYear is a const you declare. It is never inferred from timeframe, because the timeframe token is an identity tag on the bars and not a claim about trading time. A fraction, not a percentage: 0.24 is 24% annualised.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
length | Constant | number | 20 | 1 to 10000 | Window in observed bars. |
periodsPerYear | Constant | number | 252 | 1 to 31536000 | How many bars of this series make a year. 252 trading days, 52 weeks, 12 months. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
length + 1bars. Names in the warm-up are this operator’s parameters.- Missing values
- Returns na until length + 1 consecutive non-na, strictly positive observations have been seen (the first log return needs two bars, then the window needs
lengthof them). An na or a non-positive observation resets the accumulation.
Example
ta.realizedvol(close, 20, 252)plot(ta.realizedvol(close, 20, 252), "Realised volatility")