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 try it directly on TradingView: Time & Cycles Indicator
Or view and 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!