OPEN-SOURCE SCRIPT
Total Returns indicator by PtahX

PtahX Total Returns – True Total-Return View for Any Symbol
Most charts only show price. This script shows what your position actually did once you include dividends and, optionally, inflation.
What this indicator does
1. Builds a Total Return series
You choose how dividends are treated:
* Reinvest (default): All gross dividends are automatically reinvested into more shares on the ex-dividend bar.
* Cash: Dividends are kept as cash added on top of your initial position.
* Ignore: Price only, like a regular chart.
This answers: “If I bought once at the start and held, how much would that position be worth now, given this dividend policy?”
2. Optional inflation-adjusted (real) returns
You can also plot a real total-return line, which adjusts for inflation using a CPI series.
This answers: “How did my purchasing power change after inflation?”
3. Stats window and exponential trendline
You can pick the time window:
* Since inception (full available history)
* YTD
* Last 1 Year
* Last 5 Years
* Custom start date
For that window, the script:
* Normalizes Total Return to 1.0 at the window start.
* Fits an exponential trendline (pink) to the normalized series.
* Displays a stats table in the bottom-right showing:
• Overall Return (%) over the selected range
• CAGR (compound annual growth rate, % per year)
• Trendline growth (% per year)
• R² of the trendline (fit quality)
• A separate “Since inception” block (overall return and CAGR from the first bar on the chart)
How to use it
1. Add the indicator to your chart.
2. Open the settings:
Total Return & Dividends
* Dividend mode
• Reinvest: closest to a true total-return curve (default).
• Cash: price plus cash dividends.
• Ignore: price only.
* Plot inflation-adjusted TR line
• Turn this on if you want to see a real (CPI-adjusted) total-return line.
Inflation / Real Returns
* Inflation country code and field code
• Leave defaults if you just want a standard CPI series.
* Use real TR for stats & trendline
• On: stats and trendline use the inflation-adjusted curve.
• Off: stats use the nominal (non-adjusted) total return.
Stats Range & Trendline
* Stats range: Since inception, YTD, 1 Year, 5 Years, or Custom date.
* Custom date: set year, month, and day if you choose “Custom date”.
* Plot TR exponential trendline: show or hide the pink curve.
* Show stats table / Show Overall Return / Show Trendline stats: toggle what appears in the table.
3. Zoom and change timeframe as usual. The stats range is based on calendar time (YTD, 1Y, 5Y, etc.), not bar count, so the numbers stay meaningful as you change resolutions.
How to read the outputs
* Teal line: Nominal Total Return (using your chosen dividend mode).
* Orange line (if enabled): Real (inflation-adjusted) Total Return.
* Pink line (if enabled): Exponential trendline for the selected stats window.
On the right edge, small labels show the latest value of each active line.
In the bottom-right stats table:
* Overall Return: total percentage gain or loss over the chosen stats range.
* CAGR: the smoothed annual rate that would turn 1.0 into the current value over that range.
* Exponential Trendline: the average trendline growth per year and the R².
• R² near 1 means prices follow a clean exponential path.
• Lower R² means more noise or sideways movement around the trend.
* Range: which window those stats apply to (YTD, 1Y, 5Y, etc.).
* Since inception: overall return and CAGR from the first bar on the chart up to the latest bar, independent of the current stats range.
Use this when you want to compare true performance, not just price – especially for dividend-heavy ETFs, funds, and income strategies.
Most charts only show price. This script shows what your position actually did once you include dividends and, optionally, inflation.
What this indicator does
1. Builds a Total Return series
You choose how dividends are treated:
* Reinvest (default): All gross dividends are automatically reinvested into more shares on the ex-dividend bar.
* Cash: Dividends are kept as cash added on top of your initial position.
* Ignore: Price only, like a regular chart.
This answers: “If I bought once at the start and held, how much would that position be worth now, given this dividend policy?”
2. Optional inflation-adjusted (real) returns
You can also plot a real total-return line, which adjusts for inflation using a CPI series.
This answers: “How did my purchasing power change after inflation?”
3. Stats window and exponential trendline
You can pick the time window:
* Since inception (full available history)
* YTD
* Last 1 Year
* Last 5 Years
* Custom start date
For that window, the script:
* Normalizes Total Return to 1.0 at the window start.
* Fits an exponential trendline (pink) to the normalized series.
* Displays a stats table in the bottom-right showing:
• Overall Return (%) over the selected range
• CAGR (compound annual growth rate, % per year)
• Trendline growth (% per year)
• R² of the trendline (fit quality)
• A separate “Since inception” block (overall return and CAGR from the first bar on the chart)
How to use it
1. Add the indicator to your chart.
2. Open the settings:
Total Return & Dividends
* Dividend mode
• Reinvest: closest to a true total-return curve (default).
• Cash: price plus cash dividends.
• Ignore: price only.
* Plot inflation-adjusted TR line
• Turn this on if you want to see a real (CPI-adjusted) total-return line.
Inflation / Real Returns
* Inflation country code and field code
• Leave defaults if you just want a standard CPI series.
* Use real TR for stats & trendline
• On: stats and trendline use the inflation-adjusted curve.
• Off: stats use the nominal (non-adjusted) total return.
Stats Range & Trendline
* Stats range: Since inception, YTD, 1 Year, 5 Years, or Custom date.
* Custom date: set year, month, and day if you choose “Custom date”.
* Plot TR exponential trendline: show or hide the pink curve.
* Show stats table / Show Overall Return / Show Trendline stats: toggle what appears in the table.
3. Zoom and change timeframe as usual. The stats range is based on calendar time (YTD, 1Y, 5Y, etc.), not bar count, so the numbers stay meaningful as you change resolutions.
How to read the outputs
* Teal line: Nominal Total Return (using your chosen dividend mode).
* Orange line (if enabled): Real (inflation-adjusted) Total Return.
* Pink line (if enabled): Exponential trendline for the selected stats window.
On the right edge, small labels show the latest value of each active line.
In the bottom-right stats table:
* Overall Return: total percentage gain or loss over the chosen stats range.
* CAGR: the smoothed annual rate that would turn 1.0 into the current value over that range.
* Exponential Trendline: the average trendline growth per year and the R².
• R² near 1 means prices follow a clean exponential path.
• Lower R² means more noise or sideways movement around the trend.
* Range: which window those stats apply to (YTD, 1Y, 5Y, etc.).
* Since inception: overall return and CAGR from the first bar on the chart up to the latest bar, independent of the current stats range.
Use this when you want to compare true performance, not just price – especially for dividend-heavy ETFs, funds, and income strategies.
Script de código abierto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Script de código abierto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.