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:

  1. Previous High/Low Levels: Daily and weekly highs/lows with history buffers
  2. Time-based Cycles: Draw lines at intraday time anchors (e.g. 00:00, 09:30)
  3. 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")) and ta.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, and display 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! βœ¨πŸ“Š