INVITE-ONLY SCRIPT

Cycles by AlgoKings

106
Cycles by AlgoKings

RISK DISCLAIMER: This indicator is an analytical tool for educational purposes only, not financial advice. Trading carries substantial risk of loss. This tool does not guarantee profitable trades. Always use proper risk management and never risk more than you can afford to lose.

WHAT ARE CYCLES?

Cycles visualizes institutional time windows and key opening price levels. Instead of analyzing price patterns, this indicator segments the trading day into institutional order flow periods (90-minute, 30-minute, 10-minute cycles) and marks significant opening prices (session, daily, weekly, monthly, yearly) that often act as reference points for intraday price action.

Example: The 09:30 open price marks the start of regular US equity trading and often serves as a pivot level throughout the day. The London 1 (LN 1) 90-minute cycle from 02:30-04:00 EST represents the first institutional accumulation window.

UNDERLYING METHODOLOGY

This indicator combines three analytical layers:

1. INTRADAY CYCLE SEGMENTATION
Divides the trading day into institutional time windows:

ASIA SESSION:
18:00-02:30 EST (overnight session before London open)

90-MINUTE CYCLES:
Nine windows per trading day aligned with ICT methodology:
- LN 1, LN 2, LN 3: London session (02:30-04:00, 04:00-05:30, 05:30-07:00)
- AM 1, AM 2, AM 3: New York AM session (07:00-08:30, 08:30-10:00, 10:00-11:30)
- PM 1, PM 2, PM 3: New York PM session (11:30-13:00, 13:00-14:30, 14:30-16:00)

Technical implementation:
- 90m detection: Calculates ((hour * 60 + minute) - 150) % 90 == 0 to identify cycle boundaries from 02:30 EST baseline
- Session boundaries: Tracks inSession flag using time("", "0230-1600", gTimezone) to detect entry/exit from trading window
- Index tracking: Maintains counter (1-9) to assign sequential names (LN 1, AM 2, etc.) and color rotation (A/M/D pattern)

Color coding:
Each 90m cycle alternates three colors in A-M-D pattern (Accumulation-Manipulation-Distribution phases based on ICT concepts)

30-MINUTE CYCLES:
27 windows per trading day (2:30-16:00 EST), color-coded in A-M-D triplet pattern

10-MINUTE CYCLES:
81 windows per trading day (2:30-16:00 EST), single color for all

Cycle visualization:
- Box backgrounds highlight time ranges
- High/low tracked dynamically as cycle forms
- EQ (equilibrium) line at midpoint for 90m cycles
- Borders (optional) delineate cycle boundaries

2. OPENING PRICE TRACKING
Marks key opening levels that serve as institutional reference points:

SWING OPENS:
- Year Open: First price of calendar year
- Quarter Open: First price of Q1, Q2, Q3, Q4
- Month Open: First price of calendar month
- Week Open: First price of Sunday 18:00 EST (Monday for crypto)

INTRADAY OPENS:
- 00:00 Open: Midnight EST (new trading day for 24h markets)
- 09:30 Open: US equity market open
- Current Cycle Open (C.O): Opening price of most recent 90m cycle

Technical implementation:
- Period opens: Uses request.security to detect new bar on higher timeframe (time[1] != previous time[1])
- Timed opens: Pattern matches hour/minute (e.g., hour==9 and minute==30 for 09:30)
- Line extension: Opens extend right dynamically (end = time + offset) to stay visible

History parameter controls how many previous opens to display per type.

3. OVERLAP CONSOLIDATION
When multiple opens share the same price level, consolidates into single visual:

ALGORITHM:
At barstate.islast, compares all active Level objects by price coordinate. When match found, merges labels into combined text with bullet separator (e.g., "M.O, W.O •" indicates Month Open and Week Open coincide). Lower precedence level undrawn, higher precedence level preserves visual with concatenated tooltip.

This prevents chart clutter when weekly, monthly, or quarterly opens align at same price.

WHY CLOSED-SOURCE?

This script protects proprietary algorithms:

- 90m cycle detection: Custom time arithmetic ((hour * 60 + minute) - 150) % 90 == 0 that calculates exact 90-minute boundaries from 02:30 baseline, with session boundary detection to exclude overnight periods
- Cycle index management: State machine that resets index to 1 on session start, increments through 1-9, applies modulo arithmetic for color rotation (index % 3), and assigns sequential names based on position
- Dynamic range tracking: Real-time high/low updating during cycle formation (h = math.max(h, high), l = math.min(l, low)) with isFinal flag transition when cycle completes
- Timed open detection: Pattern matching on hour/minute combinations with timezone conversion (gTimezone = "America/New_York") and proper handling of 24h markets vs traditional session starts
- Overlap consolidation: Price-based comparison of all Level objects at barstate.islast, string concatenation of names, selective undrawing to maintain single visual per price level
- Day of week positioning: Complex time offset calculations (newNoonTime = time - D/2, newMidTime for Sunday handling) to center labels at day midpoints considering crypto 24/7 vs traditional market schedules

Standard cycle indicators show fixed time periods. This script provides ICT-aligned institutional windows with smart label management and multi-timeframe open tracking.

TECHNICAL COMPONENTS

Core structures:
- Security Object: Stores timeframe data (open, time, time[1]) from request.security calls, maintains isNew flag for cycle detection
- Range Object: Represents cycle box with coordinates (start, end, h, l), isFinal state, drawing objects (box, label, eq line)
- Level Object: Represents open price line with coordinates (price, start, end, startCtf), isFinal state, drawing objects (line, label)
- Option Object: Centralized settings container with cycle-specific overrides for colors, styles, history counts

Cycle detection patterns:
- 90m: if (security.isNew and ((hour * 60 + minute) - 150) % 90 == 0 and inSession)
- 30m: if (security.isNew and inSession), index cycles 1-2-3 for color
- 10m: if (security.isNew and inSession)
- Period opens: if (security.isNew) on higher timeframe
- Timed opens: if (security.isNew and hour == h and minute == m)

Extension logic:
- Ranges: end = time, h = max(h, high), l = min(l, low) while not isFinal
- Levels: end = time + offset (offset = ctfSeconds * 12000 for far-right placement)

HOW TO USE

Setup:
1. Apply to intraday chart (works best on 1m-30m timeframes)
2. Enable/disable cycle types in Time Cycles section
3. Enable/disable open types in Opens section
4. Configure History to control how many days/periods to show
5. Adjust colors and line styles to preference

Chart Timeframe Requirements:
Designed for intraday charts (seconds to 30m). Higher timeframes (1H+) will show opens but cycles may not display properly.

Interpretation:
CYCLES (Box Backgrounds):
- ASIA = Gray box covering 18:00-02:30 EST
- LN 1/2/3 = Blue/Red/Green boxes (London 90m cycles)
- AM 1/2/3 = Blue/Red/Green boxes (NY morning 90m cycles)
- PM 1/2/3 = Blue/Red/Green boxes (NY afternoon 90m cycles)
- 30m/10m = Smaller nested cycles within 90m windows
- EQ line = 50% equilibrium level within 90m cycle range

OPENS (Horizontal Lines):
- C.O = Current 90m cycle open (most recent)
- 00:00 = Midnight EST open
- 09:30 = US equity market open
- W.O = Week open (Sunday 18:00)
- M.O = Month open
- Q.O = Quarter open
- Y.O = Year open
- Bullet (•) in label = Multiple opens at same price

DAY OF WEEK:
- Labels at chart bottom (Monday, Tuesday, etc.)
- Vertical dividers at midnight (optional)

SETTINGS EXPLAINED

Time Cycles:
- Asia: Enable/disable Asia session box (18:00-02:30 EST) with color picker
- 90m Cycle: Enable/disable 90m windows with three color pickers (A/M/D phases)
- 90m EQ: Show/hide equilibrium line at midpoint of 90m cycles
- 30m Cycle: Enable/disable 30m windows with three color pickers
- 10m Cycle: Enable/disable 10m windows with single color
- Label: Size for cycle names (LN 1, AM 2, etc.)
- Border: Show/hide cycle box outlines with style picker
- History (Days): Number of days to show cycles (0-4)

Opens:
- Label: Color and size for all open price labels
- Line Width: Thickness for all open price lines
- Current Cycle: Enable/disable C.O (current 90m cycle open)
- 00:00: Enable/disable midnight open with color and history count
- 09:30: Enable/disable equity market open with color and history count
- Week: Enable/disable weekly open with color and history count
- Month: Enable/disable monthly open with color and history count
- Quarter: Enable/disable quarterly open with color and history count
- Year: Enable/disable yearly open with color and history count

History count determines how many previous opens to display (e.g., History=2 for Weekly shows this week and last week's opens)

Day of Week:
- Day: Enable/disable day name labels at chart bottom
- Divider: Enable/disable vertical lines at midnight boundaries with style picker

UPDATES

This script is actively maintained. Updates released through TradingView's native update system. For technical questions, use the comment section below.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.