Seasonality Window Stats - Roll-Adjusted and Detrended

Seasonality Window Stats measures how an instrument has historically behaved over a window that starts today (the next N sessions, or the rest of the year) and shows whether that behavior can be told apart from random noise.
WHAT IT DOES
- Averages the year-to-date path of the last N years and plots it over the current year (solid line), anchored to the previous year's close.
- Projects that average path forward from today's close for the selected window (dashed line).
- Shows a table with the window statistics: years used, mean return, number of positive years, best year and worst year.
WHAT MAKES IT DIFFERENT
1) Roll-safe returns for futures. Back-adjusted continuous contracts subtract every roll gap from older prices. In markets with persistent contango (natural gas, crude oil) this pushes old prices toward zero or below, and percentage-based seasonality produces meaningless triple-digit results. This script calculates each daily return as the move of the back-adjusted series divided by the previous unadjusted price. Roll gaps are removed and percentages stay correct, matching what a trader rolling the front contract would actually have earned. The chart's own back-adjustment setting does not change the statistics.
2) Detrend mode. Most assets rise in most years, so almost any window looks bullish. With Detrend enabled, each year's window is compared with that same year's pro-rata trend (annual log return x window length / 366). The table then shows whether the window beat its own year's pace, which isolates the pure seasonal component.
3) Built-in noise check. The "Years up" cell turns green or red only when the result would be unlikely under a coin flip (roughly 68% / 32% or beyond with 25 years). Yellow means the result cannot be distinguished from chance.
4) Windows can cross the year-end (for example mid-December to mid-January) by continuing into the following year's data.
HOW TO USE IT
1) Open a daily chart. Continuous futures (ES1!, GC1!, CL1!...), stocks, ETFs, indices, forex and crypto are supported.
2) Pick the window: "Next N sessions" (default 20, about four weeks) or "Rest of year".
3) Check the table twice: first with Detrend off, then with Detrend on.
4) Read the table:
- Years used: the sample size. Below about 15 years, treat any result as anecdotal.
- Years up / Years above trend: the main statistic. Prefer it over the mean, which a single extreme year can dominate.
- Best year / Worst year: the dispersion. A positive mean with a -20% worst year is not a low-risk tailwind.
- Average YTD today / Deviation vs trend today: where the average year stood on this date, relative to its start (or to its own trend when detrended).
HOW TO INTERPRET IT
- Green or red in both modes, plus an economic reason (heating demand, harvest, year-end flows): a seasonal tendency worth knowing.
- Green with Detrend off but yellow with Detrend on: the apparent seasonality is just the long-term drift of the asset.
- Yellow: no statistical edge. Ignore seasonality for this window.
- Use the result as context (a directional bias or a tie-breaker between signals), not as an entry signal.
SETTINGS
- Years to average (default 25).
- Window and N sessions. Sessions are converted to calendar days (x 7/5). On crypto, which trades every day, N is read as calendar days.
- Detrend.
- Adjust for dividends: for stocks and ETFs, uses dividend-adjusted prices so ex-dividend drops do not create false bearish periods. No effect on futures.
- Seasonal path, projection and color.
LIMITATIONS
- Daily timeframe only.
- The number of years depends on the history loaded on your chart; check "Years used". The first, partial year of history is discarded.
- The session-to-day conversion ignores holidays, so window end dates are approximate.
- On the live bar, the values update until the session closes.
- The futures calculation relies on TradingView's back-adjusted and unadjusted continuous data.
- The significance check is a simple binomial approximation. If you test many windows or symbols, roughly one in ten will look significant by chance alone.
- Historical seasonal behavior does not predict future results. This is a statistical study, not trading advice.
Companion script: "Seasonal Monthly Heatmap" applies the same roll-safe and detrended statistics to the twelve calendar months for up to ten symbols at once.
WHAT IT DOES
- Averages the year-to-date path of the last N years and plots it over the current year (solid line), anchored to the previous year's close.
- Projects that average path forward from today's close for the selected window (dashed line).
- Shows a table with the window statistics: years used, mean return, number of positive years, best year and worst year.
WHAT MAKES IT DIFFERENT
1) Roll-safe returns for futures. Back-adjusted continuous contracts subtract every roll gap from older prices. In markets with persistent contango (natural gas, crude oil) this pushes old prices toward zero or below, and percentage-based seasonality produces meaningless triple-digit results. This script calculates each daily return as the move of the back-adjusted series divided by the previous unadjusted price. Roll gaps are removed and percentages stay correct, matching what a trader rolling the front contract would actually have earned. The chart's own back-adjustment setting does not change the statistics.
2) Detrend mode. Most assets rise in most years, so almost any window looks bullish. With Detrend enabled, each year's window is compared with that same year's pro-rata trend (annual log return x window length / 366). The table then shows whether the window beat its own year's pace, which isolates the pure seasonal component.
3) Built-in noise check. The "Years up" cell turns green or red only when the result would be unlikely under a coin flip (roughly 68% / 32% or beyond with 25 years). Yellow means the result cannot be distinguished from chance.
4) Windows can cross the year-end (for example mid-December to mid-January) by continuing into the following year's data.
HOW TO USE IT
1) Open a daily chart. Continuous futures (ES1!, GC1!, CL1!...), stocks, ETFs, indices, forex and crypto are supported.
2) Pick the window: "Next N sessions" (default 20, about four weeks) or "Rest of year".
3) Check the table twice: first with Detrend off, then with Detrend on.
4) Read the table:
- Years used: the sample size. Below about 15 years, treat any result as anecdotal.
- Years up / Years above trend: the main statistic. Prefer it over the mean, which a single extreme year can dominate.
- Best year / Worst year: the dispersion. A positive mean with a -20% worst year is not a low-risk tailwind.
- Average YTD today / Deviation vs trend today: where the average year stood on this date, relative to its start (or to its own trend when detrended).
HOW TO INTERPRET IT
- Green or red in both modes, plus an economic reason (heating demand, harvest, year-end flows): a seasonal tendency worth knowing.
- Green with Detrend off but yellow with Detrend on: the apparent seasonality is just the long-term drift of the asset.
- Yellow: no statistical edge. Ignore seasonality for this window.
- Use the result as context (a directional bias or a tie-breaker between signals), not as an entry signal.
SETTINGS
- Years to average (default 25).
- Window and N sessions. Sessions are converted to calendar days (x 7/5). On crypto, which trades every day, N is read as calendar days.
- Detrend.
- Adjust for dividends: for stocks and ETFs, uses dividend-adjusted prices so ex-dividend drops do not create false bearish periods. No effect on futures.
- Seasonal path, projection and color.
LIMITATIONS
- Daily timeframe only.
- The number of years depends on the history loaded on your chart; check "Years used". The first, partial year of history is discarded.
- The session-to-day conversion ignores holidays, so window end dates are approximate.
- On the live bar, the values update until the session closes.
- The futures calculation relies on TradingView's back-adjusted and unadjusted continuous data.
- The significance check is a simple binomial approximation. If you test many windows or symbols, roughly one in ten will look significant by chance alone.
- Historical seasonal behavior does not predict future results. This is a statistical study, not trading advice.
Companion script: "Seasonal Monthly Heatmap" applies the same roll-safe and detrended statistics to the twelve calendar months for up to ten symbols at once.
Public data. Hidden conclusions.
warrenleaks.com
warrenleaks.com
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
Public data. Hidden conclusions.
warrenleaks.com
warrenleaks.com
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.