Historical Annual Avg Growth Lines + 1-Year ProjectionThis script creates an overlay indicator on your TradingView chart that visualizes the historical average annual growth rate of the selected instrument (e.g., TSLA) in a specific way. Here's a step-by-step summary of what it represents and how it works:
Overall Purpose
It calculates the average annual percentage gain (arithmetic mean) across the instrument's entire trading history, using non-overlapping periods of 252 trading days each (approximating one year, excluding weekends/holidays).
It then draws horizontal green lines on the chart for each complete "year" segment, showing a projected "fair value" price level for that year based on the overall average growth rate.
This helps you compare actual historical price action against what the price "would have been" if it had grown steadily at the stock's long-term average annual rate. Lines above actual prices suggest periods where growth exceeded the average (potentially overvalued in hindsight), while lines below suggest underperformance (potentially undervalued).
The calculation excludes the most recent incomplete year (any bars beyond the last full 252-day segment), ensuring only fully realized historical periods are used.
Key Calculations
Identifying Complete Years: It divides the chart's data from the first trading day (bar_index 0) into segments of exactly 252 bars each. For example:
Year 1: Bars 0 to 251
Year 2: Bars 252 to 503
And so on, up to the last full segment before the current bar.
If the total bars aren't a perfect multiple of 252, the partial current year is ignored.
Average Annual % Gain: For each complete year segment:
It computes the % gain as (end_price - start_price) / start_price.
Sums these % gains across all years and divides by the number of years to get the overall average (e.g., if TSLA averaged 42% per year historically, that's the value used).
Projected Price Lines: For each year segment:
Takes the starting price of that year.
Applies the overall average % gain to project a "target" end-of-year price: start_price * (1 + average_annual_gain).
Draws a horizontal line at that projected price level, spanning only the bars of that specific year (e.g., a flat green line covering 252 bars, positioned above or below the actual price action for visual comparison).
Visual Representation
Horizontal Lines: Each green line is flat and covers one historical year block on the chart. Earlier years (left side) will have lower projected prices (reflecting lower starting prices), while later years (right side) will have higher ones as the base price compounds over time—but each is independent and based on that year's start.
No Smoothing or Rolling: Unlike a moving average, these are static historical segments (non-overlapping), recalculated only on the last bar for efficiency.
Example on TSLA: Assuming TSLA's long-term average annual gain is ~42% (based on its history since 2010 IPO), the line for Year 1 would be at * 1.42, spanning the first 252 bars. Year 2 would start from the actual price at bar 252 and project * 1.42, and so on. If lines are consistently above actual prices in recent years, it might indicate recent growth slowing relative to historical averages.
Forward Projection (1 Year Out)
The script also extends a dashed orange horizontal line to the right of the current bar, projecting the price one year into the future based on the same historical average annual growth rate.
It starts from the end price of the last complete historical year as the base.
Applies the average % gain once more to estimate the "target" price after another 252 trading days (e.g., base_price * (1 + average_annual_gain)).
The line is dashed and orange for distinction, extending approximately 252 bars to the right (scroll or zoom right to view the full projection). This provides a visual guide for where the price "might" trend if growth continues at the historical average, helping with long-term investment planning like setting targets or assessing potential upside.
Pine Script® 인디케이터






















