OPEN-SOURCE SCRIPT
Mis à jour Grid System + Gann Diamond

This Pine Script v6 indicator, titled "Grid System + Gann Diamond", is a customizable geometric overlay tool heavily inspired by W.D. Gann's principles — particularly price-time squaring, diagonal angle projections (Gann-style angles), and grid-based subdivisions within a defined range.It identifies a historical lookback range (from a user-defined anchor time to the present) and calculates:
High (HH), Low (LL), and Midpoint of that range
A central vertical line at the time midpoint (t/2)
Main horizontal levels (top/mid/bottom)
Diagonal lines (upper/lower) radiating from the midpoint, creating a diamond-like geometric structure
Forward projections (rays) of key diagonals beyond the current bar
Optional interior grid (equal spacing or Fibonacci ratios)
Propagated/additional diagonals from midpoints, endpoints, or quarter points (¼ & ¾) along the horizontals
Current-bar vertical connections (high → mid, low → mid)
The result visually resembles a "Gann Diamond" (or extended Gann square/angle fan concept) — a geometric framework where price and time relationships are highlighted to reveal potential support/resistance, trend strength, or reversal zones when price interacts with the lines.
Key features include:
Anchor point selection (drag the time input)
Option to only draw on the last bar (cleaner chart)
Toggle for forward rays, full projected box, interior grid, quarter diagonals, etc.
Custom colors, widths, and line styles
Main Use Cases in Trading:
Geometric Support / Resistance Identification
The horizontal levels + grid lines act as static S/R zones.
Propagated diagonals and forward projections serve as dynamic future S/R lines (price often reacts when touching or crossing them).
Gann-style Angle / Trend Analysis
The main diagonals (and their forward extensions) represent Gann-like angles.
Traders watch whether price stays above/below certain diagonals to gauge trend strength (similar to classic 1×1, 2×1 angle behavior).
Range / Cycle Projection & Exhaustion Zones
The diamond/box structure helps visualize when price and time may be "squaring out" (a core Gann concept).
Useful near the right edge or projected forward area to anticipate potential reversals or acceleration.
Confluence Tool
Combine with price action, volume, other indicators (e.g. Fibonacci, pivot points, supply/demand zones).
Reactions at grid lines + diagonal crossings + quarter points often give higher-probability setups.
Swing / Range Trading Context
Very helpful on higher timeframes (4H–Daily–Weekly) to frame the larger structure after a clear swing high/low.
The anchor time can be set to major pivots, news events, cycle starts, etc.
High (HH), Low (LL), and Midpoint of that range
A central vertical line at the time midpoint (t/2)
Main horizontal levels (top/mid/bottom)
Diagonal lines (upper/lower) radiating from the midpoint, creating a diamond-like geometric structure
Forward projections (rays) of key diagonals beyond the current bar
Optional interior grid (equal spacing or Fibonacci ratios)
Propagated/additional diagonals from midpoints, endpoints, or quarter points (¼ & ¾) along the horizontals
Current-bar vertical connections (high → mid, low → mid)
The result visually resembles a "Gann Diamond" (or extended Gann square/angle fan concept) — a geometric framework where price and time relationships are highlighted to reveal potential support/resistance, trend strength, or reversal zones when price interacts with the lines.
Key features include:
Anchor point selection (drag the time input)
Option to only draw on the last bar (cleaner chart)
Toggle for forward rays, full projected box, interior grid, quarter diagonals, etc.
Custom colors, widths, and line styles
Main Use Cases in Trading:
Geometric Support / Resistance Identification
The horizontal levels + grid lines act as static S/R zones.
Propagated diagonals and forward projections serve as dynamic future S/R lines (price often reacts when touching or crossing them).
Gann-style Angle / Trend Analysis
The main diagonals (and their forward extensions) represent Gann-like angles.
Traders watch whether price stays above/below certain diagonals to gauge trend strength (similar to classic 1×1, 2×1 angle behavior).
Range / Cycle Projection & Exhaustion Zones
The diamond/box structure helps visualize when price and time may be "squaring out" (a core Gann concept).
Useful near the right edge or projected forward area to anticipate potential reversals or acceleration.
Confluence Tool
Combine with price action, volume, other indicators (e.g. Fibonacci, pivot points, supply/demand zones).
Reactions at grid lines + diagonal crossings + quarter points often give higher-probability setups.
Swing / Range Trading Context
Very helpful on higher timeframes (4H–Daily–Weekly) to frame the larger structure after a clear swing high/low.
The anchor time can be set to major pivots, news events, cycle starts, etc.
Notes de version
fixed some messy code that caused lines to duplicate....Notes de version
fixed arrays... still had some lines doubling over time. should be good now.Notes de version
reconfigured for 2 choices - random and fixed. Fixed mode divides the range using the high/low of a user selectable in bars lookback period or using Random mode uses a draggable anchor-defined range. This then prints and locks the diamond grid until either the time range is reselected or new highs/lows are hit. If new highs/lows are hit the time range will hold but the vertical will readjust. Pricing will now travel through the grid which I feel is more optimum.Notes de version
added a few lines of code to prevent any double printing of lines...Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.