ULAM CC (TDT x Gann Square of 9)
ULAM Candles Counter is a time-based sequential candle counting tool designed to track structured price progression within a defined period.
The script is a tribute to the Polish mathematician Stanisław Ulam, whose work on numerical structures and patterns inspired generations of mathematical exploration. While this indicator does not attempt to replicate formal number theory, it is conceptually inspired by the idea that structured sequences can reveal hidden order inside complex systems.
The indicator begins counting from a user-defined start date and stops at a selected end date. Each qualifying candle increments the sequence counter. The counting logic can operate in two modes:
• Breakout Mode – the counter increases only when price breaks the high or low of the last counted candle (inside candles are ignored).
• Continuous Mode – every candle within the selected time window is counted, including inside bars.
This allows traders to analyze structured expansion versus compression phases and observe how price evolves relative to previous range anchors.
The indicator highlights the selected counting period on the chart and displays the current sequence number in a corner panel (“SEQ”).
Additionally, it can mark predefined “special numbers” from selectable numerical sets. These sets include structured mathematical sequences such as progressive intervals and square numbers (n²). When the live counter reaches a value contained in the selected set, the bar is labeled with a customizable color.
Available number sets:
• 1–2
• 1–3
• 1–4
• 1–5
• 1–10
• 1–12
• Square numbers
• All Arrays (checks across all sets)
This makes the tool useful for:
• Studying structured sequence behavior inside defined sessions
• Monitoring breakout progression
• Highlighting mathematically significant sequence milestones
• Testing time-cycle hypotheses
• Building rule-based alert conditions
Built-in alerts:
• Counting Started
• Counting Ended
• Special Number Reached
The indicator does not repaint and operates entirely on confirmed bar data.
How to use it :
From my perspective, we get the best results when the second number in the sequence detects the first correction.
Alternatively, we count the series of candles before the correction
ULAM Candles Counter is a structural timing tool — it does not predict direction, but it helps visualize order, rhythm, and sequence progression within price action.
⚠️ Notes
This tool is designed for educational and analytical purposes only.
It does not generate trade signals.
Always combine with your own strategy, market context, and risk management.
Indikator Pine Script®






















