OPEN-SOURCE SCRIPT
已更新 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.
發行說明
fixed some messy code that caused lines to duplicate....發行說明
fixed arrays... still had some lines doubling over time. should be good now.發行說明
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.發行說明
added a few lines of code to prevent any double printing of lines...開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。