PROTECTED SOURCE SCRIPT

Rolling Compound Return

18
Rolling Compound Return Indicator - Summary
This indicator calculates and displays the compounded return over rolling time periods, showing how an investment would have performed if held for the specified lookback length.
How it works:

1. Rolling calculation - For each bar, looks back N periods and compounds all the returns together using the formula: (1 + return₁) × (1 + return₂) × ... × (1 + returnₙ) - 1
2. Multiple timeframes - Allows comparison of up to 3 different rolling periods simultaneously:

* Period 1 (default 20 bars): Blue line
* Period 2 (default 50 bars): Orange line
* Period 3 (default 100 bars): Purple line


3. Visual elements:

* Lines plotted as percentage returns on dedicated Y-axis
* Zero reference line to distinguish gains from losses
* Optional green/red fill showing positive/negative zones
* Info table displaying current values for each period


4. Key insight - Unlike simple moving averages of returns, this shows the actual cumulative effect of holding through all the ups and downs over the rolling window.

Use case: Helps identify whether recent price action (over your chosen lookback period) has resulted in net gains or losses, and how different time horizons compare. For example, you might see the 20-period showing +5% while the 50-period shows -2%, indicating recent strength after a longer decline.
The indicator updates on every bar to show the "rolling N-period return" at each point in time.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.