OPEN-SOURCE SCRIPT
Geometric Monthly Returns Heatmap

Overview
The Geometric Monthly Returns Heatmap is a powerful visual dashboard that breaks down asset performance by month and year. Unlike standard performance tables that only show simple arithmetic sums, this indicator calculates both Geometric and Arithmetic Year-to-Date (YTD) returns side-by-side. This allows traders to see the true compounding impact of monthly gains and losses on their equity.
How It Works & Calculations
The script initializes a dynamic table in the bottom-right corner of your chart and populates historical data using a localized historical indexing loop:
Key Features
How to Use
Disclaimer
This script is strictly for educational and informational purposes. Past performance, whether geometric or arithmetic, is not a guarantee of future market results. Always apply proper risk management.
The Geometric Monthly Returns Heatmap is a powerful visual dashboard that breaks down asset performance by month and year. Unlike standard performance tables that only show simple arithmetic sums, this indicator calculates both Geometric and Arithmetic Year-to-Date (YTD) returns side-by-side. This allows traders to see the true compounding impact of monthly gains and losses on their equity.
How It Works & Calculations
The script initializes a dynamic table in the bottom-right corner of your chart and populates historical data using a localized historical indexing loop:
- Monthly Returns ((m_ret)): Calculated using the closing price of the current month versus the closing price of the previous month: ((close / close[1]) - 1) * 100.
- Arithmetic YTD (Ari YTD): The simple linear sum of all monthly returns for that specific year ((sum R_i)).
- Geometric YTD (Geo YTD): Reflects the actual compounded return of the asset by converting percentages to multipliers, compounding them, and converting them back: ((prod (1 + R_i) - 1) times 100). This exposes the true dragging effect of large negative months on overall performance.
Key Features
- Dual YTD View: Instantly compare the linear performance against the actual compounded performance.
- Smart Data Fetching: Built using request.security arrays to pull precise monthly metrics.
- Error Handling: Features a safety check (timeframe.ismonthly) that alerts you to switch to a Monthly chart, ensuring the data arrays map perfectly to the grid.
- ]Fully Customizable Layout: Change lookback depth and color thresholds instantly via the user input menu.
How to Use
- Add the script to your chart.
- Crucial: Switch your chart timeframe to Monthly (1M). The script will throw a clear runtime error if used on lower timeframes to prevent data distortion.
- Open the script settings to adjust the lookback window (up to 30 years) or modify the positive/negative color heat thresholds to match your chart theme.
Disclaimer
This script is strictly for educational and informational purposes. Past performance, whether geometric or arithmetic, is not a guarantee of future market results. Always apply proper risk management.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.