Auto Fibonacci Time Tools 


Fibonacci analysis in the dimension most traders ignore - time.

Price levels get most of the attention in Fibonacci analysis. Retracements, extensions, channels - all of them answer the question of where. Time analysis asks a different question: when. Not where will the market react, but when is it most likely to do so. Used together, price-based and time-based Fibonacci analysis create a two-dimensional framework that identifies not just potential reaction zones but the specific windows in time when those zones carry the most weight.

This script automates both time-based Fibonacci tools available in TradingView - Trend-Based Fib Time and Fib Time Zones - anchoring them to automatically detected price swings so they update without manual intervention as the market evolves.


Automatic Swing Detection

Both tools share the same automatic pivot detection engine - ATR-based deviation and configurable bar depth - used across the dgtrd Fibonacci toolkit. When a new significant swing is confirmed, both time tools update to the new anchor immediately. Historical pivot settings allow prior swing time analyses to be displayed alongside the current one, useful for examining how time levels have intersected with price reactions across multiple structural cycles.


Trend-Based Fib Time

Trend-Based Fib Time anchors to a three-point swing structure - a start pivot, a mid pivot, and an end pivot - and projects vertical time levels forward at Fibonacci multiples of the swing's bar duration. The reference distance is the bar count between the start and mid pivots. From the end pivot, vertical lines are projected at 0, 0.382, 0.618, 1, 1.382, 1.618, 2, 2.382, 2.618, and 3 multiples of that reference distance.

The logic behind this is straightforward: if a market took a certain number of bars to move from one structural pivot to another, proportional multiples of that time span often mark windows where the next significant move begins, accelerates, or completes. The 0.618 and 1.618 levels - the golden ratio and its reciprocal - tend to be the most consistently significant.

A configurable background fill colours the zones between adjacent time levels, providing immediate visual context for which time zone the current bar sits within. Each level is independently configurable for colour, width, and line style. The baseline trend line connecting the three anchor pivots is also displayed, making the structural anchor visible.


Fib Time Zones

Fib Time Zones use a simpler two-point anchor - the most recent confirmed swing - and project vertical lines forward at pure Fibonacci sequence intervals: 2, 3, 5, 8, 13, 21, 34, 55, and 89 bar multiples of the swing duration. A -1 level is also projected backward to provide left-side context.

Unlike Trend-Based Fib Time which uses proportional ratios, Fib Time Zones use the Fibonacci sequence directly - each zone is the sum of the two preceding ones. This creates an expanding series of time windows that reflects the natural acceleration tendency of Fibonacci sequences, with wider spacing between zones as distance from the anchor increases.

The two tools serve slightly different purposes. Trend-Based Fib Time is most useful when you have a clear three-point structure and want to project proportional timing relationships forward. Fib Time Zones are faster to read and work well as a broad timing overlay across any timeframe without requiring a specific structural context.


ZigZag Structure Overlay

An optional ZigZag overlay connects confirmed swing pivots with straight lines, clarifying the structural skeleton underlying the time tool anchor points. Line colour, width, and style are independently configurable.


Alerts

Two types of alerts are built in. A structural alert fires when a new pivot high or low is detected and the time tools update to a new anchor. Time level alerts fire when the current bar reaches a specific Trend-Based Fib Time level or a specific Fib Time Zone level, with the ticker, level number, and current price included in the alert message.


All Trend-Based Fib Time levels are individually toggleable with configurable colours, widths, and line styles. Background fill transparency is configurable. Fib Time Zone colour and historical period settings are independently controlled. Both tools can be displayed simultaneously or individually.