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提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。