//@function Calculates Realized Volatility using intraday data.
//@param length The lookback period for smoothing the period volatilities (e.g., daily RVs). Default is 20.
//@param intradayTimeframe The lower timeframe string (e.g., "1", "5", "60") to sample for returns. Must be a lower timeframe than the chart. Default is "5".
//@param annualize Boolean to indicate if the volatility should be annualized. Default is true.
//@param annualPeriods Number of periods (of the main chart's timeframe) in a year for annualization. Default is 252 (assuming daily chart).
i_length_rv = input.int(20, "Smoothing Length", minval=1, tooltip="Lookback period for smoothing the period realized volatilities (e.g., daily RVs).")
i_intraday_tf_rv = input.timeframe("5", "Intraday Timeframe", tooltip="Lower timeframe for calculating intraday returns (e.g., \"1\", \"5\", \"60\"). Must be a lower timeframe than the chart.")
i_annualize_rv = input.bool(true, "Annualize Volatility", tooltip="Annualize the Realized Volatility output.")
i_annualPeriods_rv = input.int(252, "Annual Periods", minval=1, tooltip="Number of main chart periods in a year for annualization (e.g., 252 for Daily chart, 52 for Weekly).")