Investment metric
CAGR Calculator
Find the Compound Annual Growth Rate: the single smoothed yearly rate that would take a starting value to an ending value over a number of years. Enter the three inputs to compute it.
What CAGR is
The Compound Annual Growth Rate is the constant yearly rate at which an investment would have had to grow, compounding each year, to move from its starting value to its ending value over a given number of years. The formula is CAGR = (ending value ÷ beginning value)^(1 ÷ years) − 1.
The key word is compound. Because gains build on prior gains, CAGR is not the same as the total return divided by the number of years. It smooths away the bumps along the way and expresses growth as if it happened at one steady annual pace, which is why a volatile investment and a calm one can share the same CAGR despite very different journeys. That smoothing is exactly what makes it easy to compare investments held over different lengths of time.
Why CAGR is used
CAGR is used to compare the growth of different investments, funds, or portfolios on an equal, annualized footing, regardless of how long each was held. It is far more meaningful than a simple average of yearly returns because it accounts for compounding. Its main limitation is that it hides volatility: it tells you the smoothed rate, not how rough the path was, so it is often read alongside a measure of risk such as standard deviation or maximum drawdown.
CAGR describes what already happened over a specific period and is not a prediction of future growth. How you interpret it is entirely your own decision.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
CAGR summarizes an equity curve rather than a chart indicator. When you backtest a strategy on TradingView, the Strategy Tester produces the net profit and equity curve that a growth rate like this is built from. Turning your rules into that testable strategy in the first place is what PineScripter is built to do.
PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v5 or v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.