Time & Cycles Indicator for TradingView
β TradingView and Pine Script
TradingView is a powerful platform for charting, trading, and building custom indicators using its proprietary scripting language: Pine Script. With it, traders can visualize technical patterns, backtest strategies, and share custom tools with the community.
This blog post dives into one of those tools: Time & Cycles, a custom indicator that packs multiple market insights into one chart overlay.
You can view or copy the full code here: GitHub - times-and-cycles.pine
β‘ Indicator Overview: Time & Cycles
The script is structured around three core modules:
- Previous High/Low Levels: Daily and weekly highs/lows with history buffers
- Time-based Cycles: Draw lines at intraday time anchors (e.g. 00:00, 09:30)
- Sessions Boxes: Auto-detect global trading sessions and plot colorful boxes
All fully customizable, timezone-aware, and designed for intraday and daily charting.
π 1. Previous High/Low Levels
πΉ Goal
Help visualize historical support and resistance levels (PDH/PDL, PWH/PWL) to detect reaction zones.
π οΈ Logic
- Detects new day/week using
ta.change(time("D"))
andta.change(time("W"))
- Saves highs/lows and timestamps in arrays
- A
plot_level()
helper handles drawing lines and labels, avoiding duplicates
ποΈ Customization
- Number of history levels (up to 10)
- Line style, color, and optional date labels
π 2. Daily Time Cycles
πΉ Goal
Draw horizontal lines at specific times (e.g., 00:00, 09:30) to mark cycle anchors and structural pivots.
π οΈ Logic
- Detects key moments using
hour == X and minute == Y
- Records the low at that time, and bar index
- Uses
plot_level()
on the latest bar to draw the anchor
ποΈ Customization
- Separate toggle, color, and style for each cycle time
π 3. Session Blocks
πΉ Goal
Visually map trading sessions like London, New York, Asia, etc., with background boxes.
π οΈ Logic
- Convert UTC to local time using a timezone offset
- Determine session activity using string-parsed input session times (e.g., β0700-1600β)
- When a session starts, draw a
box.new()
- Dynamically update high/low during the session and label it
ποΈ Customization
- Timezone picker with 12+ options
- Enable/disable each session individually
- Label and border styling for visual clarity
βοΈ Smart Engineering Decisions
π Optimization
- Only plots at the latest bar using
barstate.islast
- Keeps buffers under 5000 bars for performance
β¨ UX for Traders
- Intuitive groupings with
group
,inline
, anddisplay
inputs - Modular function design for maintainability
- Easy to extend for new sessions or time-based signals
π Wrap-up
Time & Cycles gives you:
- Historical context with PDH/PDL and PWH/PWL lines
- Daily time anchors for market cycle detection
- Beautiful session boxes with timezone support
Itβs an all-in-one visual framework for intraday traders.
Happy trading! β¨π