OPEN-SOURCE SCRIPT

Seasonality Heatmap [QuantAlgo]

410
🟢 Overview

The Seasonality Heatmap analyzes years of historical data to reveal which months and weekdays have consistently produced gains or losses, displaying results through color-coded tables with statistical metrics like consistency scores (1-10 rating) and positive occurrence rates. By calculating average returns for each calendar month and day-of-week combination, it identifies recognizable seasonal patterns (such as which months or weekdays tend to rally versus decline) and synthesizes this into actionable buy low/sell high timing possibilities for strategic entries and exits. This helps traders and investors spot high-probability seasonal windows where assets have historically shown strength or weakness, enabling them to align positions with recurring bull and bear market patterns.
ảnh chụp nhanh
🟢 How It Works

1. Monthly Heatmap
ảnh chụp nhanh
How % Return is Calculated:
  • The indicator fetches monthly closing prices (or Open/High/Low based on user selection) and calculates the percentage change from the previous month:
    Pine Script®
    (Current Month Price - Previous Month Price) / Previous Month Price × 100
  • Each cell in the heatmap represents one month's return in a specific year, creating a multi-year historical view
  • Colors indicate performance intensity: greener/brighter shades for higher positive returns, redder/brighter shades for larger negative returns

What Averages Mean:
ảnh chụp nhanh
  • The "Avg %" row displays the arithmetic mean of all historical returns for each calendar month (e.g., averaging all Januaries together, all Februaries together, etc.)
  • This metric identifies historically recurring patterns by showing which months have tended to rise or fall on average
  • Positive averages indicate months that have typically trended upward; negative averages indicate historically weaker months
  • Example: If April shows +18.56% average, it means April has averaged a 18.56% gain across all years analyzed

What Months Up % Mean:
ảnh chụp nhanh
  • Shows the percentage of historical occurrences where that month had a positive return (closed higher than the previous month)
  • Calculated as:
    Pine Script®
    (Number of Months with Positive Returns / Total Months) × 100
  • Values above 50% indicate the month has been positive more often than negative; below 50% indicates more frequent negative months
  • Example: If October shows "64%", then 64% of all historical Octobers had positive returns

What Consistency Score Means:
ảnh chụp nhanh
  • A 1-10 rating that measures how predictable and stable a month's returns have been
  • Calculated using the coefficient of variation (standard deviation / mean) - lower variation = higher consistency
  • High scores (8-10, green): The month has shown relatively stable behavior with similar outcomes year-to-year
  • Medium scores (5-7, gray): Moderate consistency with some variability
  • Low scores (1-4, red): High variability with unpredictable behavior across different years
  • Example: A consistency score of 8/10 indicates the month has exhibited recognizable patterns with relatively low deviation

What Best Means:
ảnh chụp nhanh
  • Shows the highest percentage return achieved for that specific month, along with the year it occurred
  • Reveals the maximum observed upside and identifies outlier years with exceptional performance
  • Useful for understanding the range of possible outcomes beyond the average
  • Example: "Best: 2016: +131.90%" means the strongest January in the dataset was in 2016 with an 131.90% gain

What Worst Means:
ảnh chụp nhanh
  • Shows the most negative percentage return for that specific month, along with the year it occurred
  • Reveals maximum observed downside and helps understand the range of historical outcomes
  • Important for risk assessment even in months with positive averages
  • Example: "Worst: 2022: -26.86%" means the weakest January in the dataset was in 2022 with a 26.86% loss

2. Day-of-Week Heatmap
ảnh chụp nhanh
How % Return is Calculated:
  • Calculates the percentage change from the previous day's close to the current day's price (based on user's price source selection)
  • Returns are aggregated by day of the week within each calendar month (e.g., all Mondays in January, all Tuesdays in January, etc.)
  • Each cell shows the average performance for that specific day-month combination across all historical data
  • Formula:
    Pine Script®
    (Current Day Price - Previous Day Close) / Previous Day Close × 100

What Averages Mean:
ảnh chụp nhanh
  • The "Avg %" row at the bottom aggregates all months together to show the overall average return for each weekday
  • Identifies broad weekly patterns across the entire dataset
  • Calculated by summing all daily returns for that weekday across all months and dividing by total observations
  • Example: If Monday shows +0.04%, Mondays have averaged a 0.04% change across all months in the dataset

What Days Up % Mean:
ảnh chụp nhanh
  • Shows the percentage of historical occurrences where that weekday had a positive return
  • Calculated as:
    Pine Script®
    (Number of Positive Days / Total Days Observed) × 100
  • Values above 50% indicate the day has been positive more often than negative; below 50% indicates more frequent negative days
  • Example: If Fridays show "54%", then 54% of all Fridays in the dataset had positive returns

What Consistency Score Means:
ảnh chụp nhanh
  • A 1-10 rating measuring how stable that weekday's performance has been across different months
  • Based on the coefficient of variation of daily returns for that weekday across all 12 months
  • High scores (8-10, green): The weekday has shown relatively consistent behavior month-to-month
  • Medium scores (5-7, gray): Moderate consistency with some month-to-month variation
  • Low scores (1-4, red): High variability across months, with behavior differing significantly by calendar month
  • Example: A consistency score of 7/10 for Wednesdays means they have performed with moderate consistency throughout the year

What Best Means:
ảnh chụp nhanh
  • Shows which calendar month had the strongest average performance for that specific weekday
  • Identifies favorable day-month combinations based on historical data
  • Format shows the month abbreviation and the average return achieved
  • Example: "Best: Oct: +0.20%" means Mondays averaged +0.20% during October months in the dataset

What Worst Means:
ảnh chụp nhanh
  • Shows which calendar month had the weakest average performance for that specific weekday
  • Identifies historically challenging day-month combinations
  • Useful for understanding which month-weekday pairings have shown weaker performance
  • Example: "Worst: Sep: -0.35%" means Tuesdays averaged -0.35% during September months in the dataset

3. Optimal Timing Table/Summary Table
ảnh chụp nhanh
→ Best Month to BUY: Identifies the month with the lowest average return (most negative or least positive historically), representing periods where prices have historically been relatively lower
  • Based on the observation that buying during historically weaker months may position for subsequent recovery
  • Shows the month name, its average return, and color-coded performance
  • Example: If May shows -0.86% as "Best Month to BUY", it means May has historically averaged -0.86% in the analyzed period

→ Best Month to SELL: Identifies the month with the highest average return (most positive historically), representing periods where prices have historically been relatively higher
  • Based on historical strength patterns in that month
  • Example: If July shows +1.42% as "Best Month to SELL", it means July has historically averaged +1.42% gains

→ 2nd Best Month to BUY: The second-lowest performing month based on average returns
  • Provides an alternative timing option based on historical patterns
  • Offers flexibility for staged entries or when the primary month doesn't align with strategy
  • Example: Identifies the next-most favorable historical buying period

→ 2nd Best Month to SELL: The second-highest performing month based on average returns
  • Provides an alternative exit timing based on historical data
  • Useful for staged profit-taking or multiple exit opportunities
  • Identifies the secondary historical strength period

Note: The same logic applies to "Best Day to BUY/SELL" and "2nd Best Day to BUY/SELL" rows, which identify weekdays based on average daily performance across all months. Days with lowest averages are marked as buying opportunities (historically weaker days), while days with highest averages are marked for selling (historically stronger days).

🟢 Examples
  • Example 1: NVIDIA NVDA - Strong May Pattern with High Consistency

ảnh chụp nhanh
Analyzing NVIDIA from 2015 onwards, the Monthly Heatmap reveals May averaging +15.84% with 82% of months being positive and a consistency score of 8/10 (green). December shows -1.69% average with only 40% of months positive and a low 1/10 consistency score (red). The Optimal Timing table identifies December as "Best Month to BUY" and May as "Best Month to SELL." A trader recognizes this high-probability May strength pattern and considers entering positions in late December when prices have historically been weaker, then taking profits in May when the seasonal tailwind typically peaks. The high consistency score in May (8/10) provides additional confidence that this pattern has been relatively stable year-over-year.
  • Example 2: Crypto Market Cap TOTALES - October Rally Pattern

ảnh chụp nhanh
An investor examining total crypto market capitalization notices September averaging -2.42% with 45% of months positive and 5/10 consistency, while October shows a dramatic shift with +16.69% average, 90% of months positive, and an exceptional 9/10 consistency score (blue). The Day-of-Week heatmap reveals Mondays averaging +0.40% with 54% positive days and 9/10 consistency (blue), while Thursdays show only +0.08% with 1/10 consistency (yellow). The investor uses this multi-layered analysis to develop a strategy: enter crypto positions on Thursdays during late September (combining the historically weak month with the less consistent weekday), then hold through October's historically strong period, considering exits on Mondays when intraweek strength has been most consistent.
  • Example 3: Solana SOLUSDT - Extreme January Seasonality

ảnh chụp nhanh
A cryptocurrency trader analyzing Solana observes an extraordinary January pattern: +59.57% average return with 60% of months positive and 8/10 consistency (teal), while May shows -9.75% average with only 33% of months positive and 6/10 consistency. August also displays strength at +59.50% average with 7/10 consistency. The Optimal Timing table confirms May as "Best Month to BUY" and January as "Best Month to SELL." The Day-of-Week data shows Sundays averaging +0.77% with 8/10 consistency (teal). The trader develops a seasonal rotation strategy: accumulate SOL positions during May weakness, hold through the historically strong January period (which has shown this extreme pattern with reasonable consistency), and specifically target Sunday exits when the weekday data shows the most recognizable strength pattern.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.