OPEN-SOURCE SCRIPT
DB Seasonal by Date Range

About This Script
This script/indicator was written in the following manner: 'I supplied logic steps through AI prompts and AI did the heavy lifting of code production. I am not a code writer by any standard at all compared to those who freely share their work with the rest of us. I have taken some Pascal classes in college, but never used coding in my career. I would like to thank all code writers who have advanced and shared their tools with the public.'
This description was drafted by Claude Opus 4.5 (Anthropic) as part of the collaborative development process.
What This Indicator Does
DB Seasonal By Date Range analyzes historical price performance within user-defined calendar periods. Set a start month/day and end month/day, and the indicator calculates returns for that window across multiple years—helping you identify recurring seasonal patterns in any asset.
Key Features
📊 Two Information Tables:
Detail Table (Top Left): Year-by-year returns for your specified lookback period (adjustable, default 10 years)
ALL DATA Table (Bottom Right): Summary statistics across all available TradingView history (up to 50 years)
📈 Statistics Provided:
Return % per year
Cumulative total return
Average return
Win rate (% positive years)
Maximum gain/loss
🎨 Visual Highlighting:
Selected date range appears as a shaded overlay on the price chart
⚙️ Customization:
Adjustable lookback period (1-20 years)
Maximum years to analyze (10-100)
Table text size (Tiny/Small/Normal/Large)
Highlight color
How It Handles Holidays & Weekends
The indicator works with actual trading data only. TradingView charts contain no bars for holidays or weekends, so:
Scenario What Happens
Start date = Holiday Uses first available trading day after
End date = Holiday Uses last available trading day before
Holiday within range Simply skipped (no bar exists)
Export as CSV
No manual adjustment needed—returns reflect real market performance during open sessions.
Cross-Year Ranges
You can study periods spanning two calendar years (e.g., November 1 → January 31 for "holiday rally" analysis). When end month < start month, the code automatically extends the end date into the following year. Seasons are labeled by the start year (e.g., Nov 2025 → Jan 2026 = "2025").
Data Anomalies to Watch For
If the ALL DATA table shows unexpected year counts, check the asset's history for:
Privatization periods (e.g., DELL was private 2013-2018)
Ticker changes (e.g., FB → META)
Spin-offs or mergers
Recent IPOs with limited history
The indicator accurately reflects available trading data—gaps in corporate history will appear as fewer years analyzed.
How to Use
Set your Start Month/Day and End Month/Day
Adjust Lookback Years for the detail table
Apply to any chart—the shaded area highlights your seasonal window
Compare year-by-year returns and long-term statistics
Use on different symbols to find assets with consistent seasonal behavior
Example Use Cases
Turn-of-Month Effect: Study last/first trading days of each month
Holiday Rallies: November through January performance
Earnings Seasons: Quarterly patterns around reporting periods
Sector Rotation: Compare seasonal trends across sector ETFs
Disclaimer
This indicator is for educational and informational purposes only. Past seasonal performance does not guarantee future results. Always conduct your own research before making trading decisions.
Acknowledgments
Logic & Concept: dbb
Code Production: Claude Opus 4.5 (Anthropic AI)
Description: Claude Opus 4.5 (Anthropic AI)
Inspiration: The generous TradingView community members who share their work freely
Questions or feedback? Leave a comment below!
This script/indicator was written in the following manner: 'I supplied logic steps through AI prompts and AI did the heavy lifting of code production. I am not a code writer by any standard at all compared to those who freely share their work with the rest of us. I have taken some Pascal classes in college, but never used coding in my career. I would like to thank all code writers who have advanced and shared their tools with the public.'
This description was drafted by Claude Opus 4.5 (Anthropic) as part of the collaborative development process.
What This Indicator Does
DB Seasonal By Date Range analyzes historical price performance within user-defined calendar periods. Set a start month/day and end month/day, and the indicator calculates returns for that window across multiple years—helping you identify recurring seasonal patterns in any asset.
Key Features
📊 Two Information Tables:
Detail Table (Top Left): Year-by-year returns for your specified lookback period (adjustable, default 10 years)
ALL DATA Table (Bottom Right): Summary statistics across all available TradingView history (up to 50 years)
📈 Statistics Provided:
Return % per year
Cumulative total return
Average return
Win rate (% positive years)
Maximum gain/loss
🎨 Visual Highlighting:
Selected date range appears as a shaded overlay on the price chart
⚙️ Customization:
Adjustable lookback period (1-20 years)
Maximum years to analyze (10-100)
Table text size (Tiny/Small/Normal/Large)
Highlight color
How It Handles Holidays & Weekends
The indicator works with actual trading data only. TradingView charts contain no bars for holidays or weekends, so:
Scenario What Happens
Start date = Holiday Uses first available trading day after
End date = Holiday Uses last available trading day before
Holiday within range Simply skipped (no bar exists)
Export as CSV
No manual adjustment needed—returns reflect real market performance during open sessions.
Cross-Year Ranges
You can study periods spanning two calendar years (e.g., November 1 → January 31 for "holiday rally" analysis). When end month < start month, the code automatically extends the end date into the following year. Seasons are labeled by the start year (e.g., Nov 2025 → Jan 2026 = "2025").
Data Anomalies to Watch For
If the ALL DATA table shows unexpected year counts, check the asset's history for:
Privatization periods (e.g., DELL was private 2013-2018)
Ticker changes (e.g., FB → META)
Spin-offs or mergers
Recent IPOs with limited history
The indicator accurately reflects available trading data—gaps in corporate history will appear as fewer years analyzed.
How to Use
Set your Start Month/Day and End Month/Day
Adjust Lookback Years for the detail table
Apply to any chart—the shaded area highlights your seasonal window
Compare year-by-year returns and long-term statistics
Use on different symbols to find assets with consistent seasonal behavior
Example Use Cases
Turn-of-Month Effect: Study last/first trading days of each month
Holiday Rallies: November through January performance
Earnings Seasons: Quarterly patterns around reporting periods
Sector Rotation: Compare seasonal trends across sector ETFs
Disclaimer
This indicator is for educational and informational purposes only. Past seasonal performance does not guarantee future results. Always conduct your own research before making trading decisions.
Acknowledgments
Logic & Concept: dbb
Code Production: Claude Opus 4.5 (Anthropic AI)
Description: Claude Opus 4.5 (Anthropic AI)
Inspiration: The generous TradingView community members who share their work freely
Questions or feedback? Leave a comment below!
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.