Rolling Portfolio Metrics for Benchmark Risk and Return Comparison
Summary
This indicator calculates rolling return and risk statistics for a traded instrument and compares returns with a selectable equity benchmark. Inputs control the benchmark, lookback length, return convention, and displayed metric group. Outputs include mean return, standard deviation, variance, correlation, squared correlation, beta, and an alpha estimate using a risk-free rate. It also plots measures labeled maximum drawdown and maximum gain, derived from the rolling mean and the period's lowest or highest return.
The script is a calculation and visualization tool, not a trading strategy, and the document provides no portfolio results or validation. Its drawdown and gain formulas use individual return extremes relative to the mean, so they are not conventional peak-to-trough equity drawdown or cumulative gain measures. The source also requests benchmark and risk-free series with lookahead enabled, which can introduce future information into historical values. Users should verify data alignment, units, and formulas before relying on the displayed statistics.
Key ideas
- The indicator compares an instrument's rolling returns with a selected benchmark and risk-free rate.
- It displays rolling volatility, variance, correlation, squared correlation, beta, and a CAPM-style alpha estimate.
- The measures labeled maximum drawdown and maximum gain are calculated from return extremes and the rolling mean.
- The benchmark and risk-free series use lookahead settings that may expose future data in historical calculations.
- The script presents metrics but supplies no validation, and its drawdown measure is not a conventional equity-curve drawdown.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.