OPEN-SOURCE SCRIPT
Seasonality [theUltimator5]

Seasonality is a unique multi-timeframe price-pattern indicator that projects the typical historical path of an asset through the current year, month, week, or trading day.
Rather than averaging raw prices, this indicator normalizes each historical period to its opening value. This allows periods with very different price levels to be compared on an equal basis. The normalized historical paths are then combined using either the median or arithmetic mean to create a 'seasonal' curve. The term 'seasonal' is used loosely since that generally applies to the yearly trends, but this indicator can break down the chart into shorter timeframes to show periodic trends rather than just yearly ones.
The current-period curve is projected forward across the chart, providing a visual estimate of where price has historically tended to strengthen, weaken, consolidate, or reverse during comparable portions of previous periods.
The indicator supports four profiling modes:
1) Yearly: Uses daily bars to compare the current year with previous years.
2) Monthly: Uses hourly bars to compare the current month with previous months.
3) Weekly: Uses 30-minute bars to compare the current week with previous weeks.
4) Daily: Uses 5-minute bars to compare the current trading day with previous trading days.
Each mode should be used on a chart timeframe at or below its native calculation timeframe:
Yearly: 4-hour through daily charts
Monthly: 15-minute through hourly charts
Weekly: 5-minute through 30-minute charts
Daily: 1-minute through 5-minute charts
A warning is displayed when the selected chart timeframe is outside the recommended range.
The seasonal pattern is calculated from a rolling historical window.
For example, a lookback of 20 in Yearly mode uses up to the previous 20 years. A lookback of 20 in Daily mode uses the previous 20 observed trading days.
The calculation only includes periods that actually traded during each seasonal slot. Holidays, missing sessions, shortened sessions, and unavailable bars are excluded rather than treated as zero values.
Two averaging methods are available:
1) Median is the default method. The median reduces the influence of unusually strong or weak historical periods and often produces a more representative seasonal path.
2) Mean calculates the standard arithmetic average of all available historical observations. This method is more responsive to extreme historical moves and is not recommended on symbols that have experienced volatility on a lookback time period orders of magnitude higher than the other periods. It will completely blow out the chart and skew it towards that single outlier period.
The indicator includes three methods for positioning the normalized seasonal curve on the current price chart.
1) Scale Only (Default)
The seasonal curve is vertically rescaled so its projected high-to-low range matches the actual high-to-low range of either the current or previous period.
The curve remains anchored to the current period’s first close.
This retains the historical seasonal shape while adapting its magnitude to the asset’s recent volatility.
2) Chained — No Fit
The original normalized seasonal path is anchored to the first close of the current period.
Historical curves are chained together so the end of one period connects continuously with the beginning of the next. No additional adjustment is made to match the asset’s current trading range.
3) Rotate & Scale
This mode applies the same range adjustment as Scale Only, then gradually rotates the current-period curve so it passes through the live price at the current bar.
The adjustment begins at zero near the start of the period and increases progressively toward the current bar. This allows the future seasonal path to remain connected to current price without abruptly shifting the entire curve.
Because this mode incorporates the live price, the projected curve can change as the current period develops.
When using Scale Only or Rotate & Scale, the user can choose which actual price range controls the vertical scaling.
1) Current Period uses the developing high and low of the current year, month, week, or day.
The curve may rescale as new highs or lows occur.
2) Previous Period uses the completed high and low of the prior period.
This creates a more stable projection that does not continually rescale during the current period.
The Draw Curve Back setting controls how many completed periods are displayed behind the current seasonal projection.
Historical seasonal curves are shown in gray and are chained together into a continuous path. The current period is displayed separately using the selected seasonality color.
Displaying previous curves can help identify how the rolling seasonal model evolved over time and whether the current projection is consistent with earlier versions of the model.
Higher draw-back settings may require more processing, particularly on intraday charts.
Smoothing
A trailing simple moving average can be applied along the seasonal curve.
A smoothing value of 1 disables smoothing. Higher values reduce short-term noise but may also soften or delay smaller seasonal turning points.
Min/Max Envelope
The minimum and maximum lines show the strongest and weakest normalized historical paths observed at each seasonal point within the selected lookback.
These lines use the same normalization, chaining, smoothing, scaling, and rotation calculations as the primary seasonal curve.
Because different slots may contain different sample sizes, the minimum and maximum lines should be interpreted as a historical range rather than a guaranteed boundary.
Current-Period Projection
For completed portions of the current period, the curve is aligned with actual timestamps.
For seasonal slots that have not yet occurred, the indicator projects timestamps forward so the curve extends into the future.
Seasonality describes recurring historical tendencies. It does not predict that price must follow the displayed curve.
Rather than averaging raw prices, this indicator normalizes each historical period to its opening value. This allows periods with very different price levels to be compared on an equal basis. The normalized historical paths are then combined using either the median or arithmetic mean to create a 'seasonal' curve. The term 'seasonal' is used loosely since that generally applies to the yearly trends, but this indicator can break down the chart into shorter timeframes to show periodic trends rather than just yearly ones.
The current-period curve is projected forward across the chart, providing a visual estimate of where price has historically tended to strengthen, weaken, consolidate, or reverse during comparable portions of previous periods.
The indicator supports four profiling modes:
1) Yearly: Uses daily bars to compare the current year with previous years.
2) Monthly: Uses hourly bars to compare the current month with previous months.
3) Weekly: Uses 30-minute bars to compare the current week with previous weeks.
4) Daily: Uses 5-minute bars to compare the current trading day with previous trading days.
Each mode should be used on a chart timeframe at or below its native calculation timeframe:
Yearly: 4-hour through daily charts
Monthly: 15-minute through hourly charts
Weekly: 5-minute through 30-minute charts
Daily: 1-minute through 5-minute charts
A warning is displayed when the selected chart timeframe is outside the recommended range.
The seasonal pattern is calculated from a rolling historical window.
For example, a lookback of 20 in Yearly mode uses up to the previous 20 years. A lookback of 20 in Daily mode uses the previous 20 observed trading days.
The calculation only includes periods that actually traded during each seasonal slot. Holidays, missing sessions, shortened sessions, and unavailable bars are excluded rather than treated as zero values.
Two averaging methods are available:
1) Median is the default method. The median reduces the influence of unusually strong or weak historical periods and often produces a more representative seasonal path.
2) Mean calculates the standard arithmetic average of all available historical observations. This method is more responsive to extreme historical moves and is not recommended on symbols that have experienced volatility on a lookback time period orders of magnitude higher than the other periods. It will completely blow out the chart and skew it towards that single outlier period.
The indicator includes three methods for positioning the normalized seasonal curve on the current price chart.
1) Scale Only (Default)
The seasonal curve is vertically rescaled so its projected high-to-low range matches the actual high-to-low range of either the current or previous period.
The curve remains anchored to the current period’s first close.
This retains the historical seasonal shape while adapting its magnitude to the asset’s recent volatility.
2) Chained — No Fit
The original normalized seasonal path is anchored to the first close of the current period.
Historical curves are chained together so the end of one period connects continuously with the beginning of the next. No additional adjustment is made to match the asset’s current trading range.
3) Rotate & Scale
This mode applies the same range adjustment as Scale Only, then gradually rotates the current-period curve so it passes through the live price at the current bar.
The adjustment begins at zero near the start of the period and increases progressively toward the current bar. This allows the future seasonal path to remain connected to current price without abruptly shifting the entire curve.
Because this mode incorporates the live price, the projected curve can change as the current period develops.
When using Scale Only or Rotate & Scale, the user can choose which actual price range controls the vertical scaling.
1) Current Period uses the developing high and low of the current year, month, week, or day.
The curve may rescale as new highs or lows occur.
2) Previous Period uses the completed high and low of the prior period.
This creates a more stable projection that does not continually rescale during the current period.
The Draw Curve Back setting controls how many completed periods are displayed behind the current seasonal projection.
Historical seasonal curves are shown in gray and are chained together into a continuous path. The current period is displayed separately using the selected seasonality color.
Displaying previous curves can help identify how the rolling seasonal model evolved over time and whether the current projection is consistent with earlier versions of the model.
Higher draw-back settings may require more processing, particularly on intraday charts.
Smoothing
A trailing simple moving average can be applied along the seasonal curve.
A smoothing value of 1 disables smoothing. Higher values reduce short-term noise but may also soften or delay smaller seasonal turning points.
Min/Max Envelope
The minimum and maximum lines show the strongest and weakest normalized historical paths observed at each seasonal point within the selected lookback.
These lines use the same normalization, chaining, smoothing, scaling, and rotation calculations as the primary seasonal curve.
Because different slots may contain different sample sizes, the minimum and maximum lines should be interpreted as a historical range rather than a guaranteed boundary.
Current-Period Projection
For completed portions of the current period, the curve is aligned with actual timestamps.
For seasonal slots that have not yet occurred, the indicator projects timestamps forward so the curve extends into the future.
Seasonality describes recurring historical tendencies. It does not predict that price must follow the displayed curve.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.