Indicator · Pine Script v6 · On the chart

Hourly Seasonality

by piecioshka

This indicator colors the chart background on intraday timeframes based on the current hour of the day.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code103
Settings4inputs
LicenceMIT
Last update10 days ago18 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

103 lines of Pine Script v6 from indicators/seasonality/hourly-seasonality/hourly-seasonality.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

hourly-seasonality.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Piotr Kowalski "piecioshka"
// Docs (EN): https://github.com/piecioshka/tradingview-pine-scripts/blob/main/indicators/seasonality/hourly-seasonality/hourly-seasonality.md
// Docs (PL): https://github.com/piecioshka/tradingview-pine-scripts/blob/main/indicators/seasonality/hourly-seasonality/hourly-seasonality.pl.md

//@version=6
indicator('Hourly Seasonality', overlay = true)

// Colors the chart background differently depending on the hour.
// Designed for intraday timeframes (< 1D) - on daily and above hour()
// always returns the same candle-open hour and the effect disappears.
// Time zone: the exchange default (same as hour() without a timezone argument).
// Colors follow a daily gradient (night → dawn → day → dusk → night),
// so neighboring hours are visually close to each other.

transp         = input.int(title='Transparency (0-100)', defval=80, minval=0, maxval=100, step=5)
showLegend     = input.bool(title='Show legend', defval=true)
legendPosition = input.string(title='Legend position', defval='Top right', options=['Top left', 'Top right', 'Bottom left', 'Bottom right'])
hoursSpec      = input.string(title='Active hours', defval='0-23', tooltip='Comma-separated ranges, e.g. "9-16,18,22". "0-23" = all.')

// 24 colors - a daily gradient
col00 = color.rgb(20, 30, 90)     // 00 - navy (deep night)
col01 = color.rgb(30, 35, 105)    // 01
col02 = color.rgb(45, 40, 125)    // 02
col03 = color.rgb(65, 45, 145)    // 03 - navy violet
col04 = color.rgb(90, 55, 155)    // 04
col05 = color.rgb(125, 70, 160)   // 05 - violet
col06 = color.rgb(170, 90, 150)   // 06 - dawn
col07 = color.rgb(220, 130, 110)  // 07 - sunrise
col08 = color.rgb(240, 160, 70)   // 08 - morning sun
col09 = color.rgb(250, 190, 50)   // 09 - morning amber
col10 = color.rgb(245, 220, 60)   // 10 - yellow
col11 = color.rgb(210, 230, 90)   // 11 - lime
col12 = color.rgb(120, 220, 180)  // 12 - noon
col13 = color.rgb(80, 200, 230)   // 13 - afternoon blue
col14 = color.rgb(70, 170, 240)   // 14
col15 = color.rgb(95, 150, 230)   // 15
col16 = color.rgb(160, 160, 210)  // 16 - transition
col17 = color.rgb(230, 160, 100)  // 17 - golden hour
col18 = color.rgb(235, 110, 70)   // 18 - sunset
col19 = color.rgb(220, 70, 80)    // 19 - sunset red
col20 = color.rgb(180, 55, 125)   // 20 - magenta dusk
col21 = color.rgb(130, 50, 145)   // 21 - dusk violet
col22 = color.rgb(80, 40, 125)    // 22 - night
col23 = color.rgb(45, 35, 105)    // 23 - late night

// Hour-range parser: "9-16,18,22" → array<bool>[24]
parseHours(spec) =>
    enabled = array.new<bool>(24, false)
    if str.length(spec) > 0
        tokens = str.split(spec, ',')
        for token in tokens
            trimmed = str.trim(token)
            if str.length(trimmed) > 0
                if str.contains(trimmed, '-')
                    parts = str.split(trimmed, '-')
                    if array.size(parts) == 2
                        sN = str.tonumber(str.trim(array.get(parts, 0)))
                        eN = str.tonumber(str.trim(array.get(parts, 1)))
                        if not na(sN) and not na(eN)
                            s = int(math.round(sN))
                            e = int(math.round(eN))
                            if s >= 0 and e <= 23 and s <= e
                                for i = s to e
                                    array.set(enabled, i, true)
                else
                    n = str.tonumber(trimmed)
                    if not na(n)
                        idx = int(math.round(n))
                        if idx >= 0 and idx <= 23
                            array.set(enabled, idx, true)
    enabled

var enabled = parseHours(hoursSpec)
var colors  = array.from(col00, col01, col02, col03, col04, col05, col06, col07, col08, col09, col10, col11, col12, col13, col14, col15, col16, col17, col18, col19, col20, col21, col22, col23)

h = hour(time)
bgCol = array.get(enabled, h) ? color.new(array.get(colors, h), transp) : na
bgcolor(bgCol)

// Legend - a table with the active hours and their colors
if showLegend and barstate.islast
    pos = switch legendPosition
        'Top left'     => position.top_left
        'Top right'    => position.top_right
        'Bottom left'  => position.bottom_left
        'Bottom right' => position.bottom_right
        =>                position.top_right

    activeCount = 0
    for i = 0 to 23
        if array.get(enabled, i)
            activeCount += 1

    if activeCount > 0
        legend = table.new(position = pos, columns = 2, rows = activeCount, border_width = 1)
        row = 0
        for i = 0 to 23
            if array.get(enabled, i)
                hourLabel = str.format('{0,number,00}:00', i)
                table.cell(legend, 0, row, '    ', bgcolor = array.get(colors, i))
                table.cell(legend, 1, row, hourLabel, text_color = color.white, bgcolor = color.new(color.black, 30))
                row += 1

Overview

Hourly Seasonality applies a continuous 24-color daily gradient transitioning across dawn, day, dusk, and night to help traders visually track time progression. Users can filter specific active hours via a comma-separated range string, adjust background transparency, and display an optional on-chart legend in various corner positions. It operates directly as an overlay on the main price chart and does not generate trading signals.

Details

Published by

piecioshka on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Sessions & time

Markets

Any symbol

Timeframes

M1-M5, M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescriptpinescript-indicatorspinescript-strategiestradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Transparency (0-100)int80transp
Show legendbooltrueshowLegend
Legend positionstringTop rightlegendPosition
Active hoursstring0-23hoursSpec
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

948 stars

This indicator counts down to a fixed Litecoin halving timestamp in August 2019, using Greenwich Mean Time. It subtracts the current time from that stamp and formats the remaining days, hours, minutes, and seconds. The day, hour, and minute of the target are u

Indicator v4 Sessions & time
Updated 10 days ago · GPL-3.0 GitHub repository of Litecoin Halving UTC Countdown
575 stars

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener

This indicator identifies and plots key options expiration dates on the price chart. It calculates monthly OpEx (the third Friday of each month), quarterly OpEx (March, June, September, December), and corresponding VIX expiration dates, drawing vertical lines

Indicator v6 Sessions & time
Updated 2 months ago · MIT GitHub repository of Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES
219 stars

This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in

Indicator v4 Support & resistanceSessions & time
Updated 5 years ago · None stated GitHub repository of 昨日高低點標示

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers