OPEN-SOURCE SCRIPT
200W SMA Annual CAGR Tracker

A Pine Script indicator that calculates the annualized Compound Annual Growth Rate (CAGR) for either the weekly close price or the weekly 200-period Simple Moving Average (200W SMA). The script allows users to choose a custom lookback period expressed in years, months, or weeks, and it displays both the reference series and the computed CAGR as a chart label and an optional summary table.
Features:
Weekly reference series plotting:
200W SMA
Weekly close
Annual CAGR calculation over configurable lookback periods
Custom lookback unit: years, months, or weeks
Optional on-chart label with CAGR value
Optional table summary showing current value, past value, CAGR, and lookback duration
Use Case:
Ideal for long-term traders and investors who want a quick visual gauge of how the weekly trend or 200-week moving average has performed on an annualized basis. Great for comparing price momentum against a slow-moving trend benchmark.
How to Use:
Select the reference type: 200W or Weekly
Choose the lookback length and unit
Enable labels and/or the table for a cleaner visual summary
Apply to weekly or lower timeframes to view the weekly reference and CAGR overlay
Note:
This indicator uses historical weekly data with lookahead=barmerge.lookahead_off to avoid repainting.
Features:
Weekly reference series plotting:
200W SMA
Weekly close
Annual CAGR calculation over configurable lookback periods
Custom lookback unit: years, months, or weeks
Optional on-chart label with CAGR value
Optional table summary showing current value, past value, CAGR, and lookback duration
Use Case:
Ideal for long-term traders and investors who want a quick visual gauge of how the weekly trend or 200-week moving average has performed on an annualized basis. Great for comparing price momentum against a slow-moving trend benchmark.
How to Use:
Select the reference type: 200W or Weekly
Choose the lookback length and unit
Enable labels and/or the table for a cleaner visual summary
Apply to weekly or lower timeframes to view the weekly reference and CAGR overlay
Note:
This indicator uses historical weekly data with lookahead=barmerge.lookahead_off to avoid repainting.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.