gannSquare

The Gann Square is a powerful tool that aligns time and price into a 1:1 square grid. By placing it between two anchor points, you can study how markets often balance when time and price move in harmony. Traders use it to project likely support/resistance levels and turning points in both horizontal (time) and vertical (price) dimensions.

Syntax

gannSquare(originPoint, targetPoint, styles?)

Parameters

originPoint (PricedData) · The first anchor (time & price) where the square begins. targetPoint (PricedData) · The second anchor (time & price) that defines the opposite corner, setting the square size. styles (GannSquareStyleOverrides) · Style configuration to customize look and levels:

  • fillBackground (boolean) · Fill the inside area of the square.

  • transparency (number) · Adjust background transparency (0–100).

  • showLabels (boolean) · Display labels on divisions.

  • priceLevels (array of numbers) · Horizontal ratio levels (e.g., [0.25, 0.5, 1]).

  • timeLevels (array of numbers) · Vertical ratio levels (e.g., [0.25, 0.5, 1]).

  • grid (LinesLevels without coeff) · Default grid style (linestyle, linewidth, color).

  • border (LinesLevels without coeff) · Style for the outer square border.

Return Value

(string) · The drawing ID of the created Gann Square.

Example

Every 40 candles, we draw a Gann Square from a past swing low up to a more recent swing high, dividing it into simple proportional levels.

Tips

  • Use clear swing highs/lows as anchors so the square naturally fits the market rhythm.

  • Start with just a few levels (0.25, 0.5, 1) to keep the chart readable.

Warning

  • Do not confuse originPoint/targetPoint with raw time() or price values. Always build them using newPoint(time(offset), price).

Good Practice

  • Maintain a consistent style (const style) for your Gann tools so your backtests and chart studies are comparable.

  • Combine with Fibonacci retracements or channels to strengthen areas of confluence.

Last updated