gannbox

The Gann Box is a time–price tool that places a squared grid between two anchors. It helps traders measure market balance, project possible reversal zones, and study cycles by dividing both time and price into proportional segments.

Syntax

gannbox(startTime, topPrice, endTime, bottomPrice, styles?)

Parameters

startTime (number) · The starting candle time for the left edge of the box. topPrice (number) · Price value for the top boundary. endTime (number) · The ending candle time for the right edge of the box. bottomPrice (number) · Price value for the bottom boundary. styles (GannBoxStyleOverrides) · Optional style settings to customize look and levels:

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

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

  • showLabels (boolean) · Display labels for divisions.

  • priceLevels (array of numbers) · Ratios for horizontal divisions (e.g., [0.25, 0.5, 1]).

  • timeLevels (array of numbers) · Ratios for vertical divisions (e.g., [0.25, 0.5, 1]).

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

  • border (LinesLevels without coeff) · Style for the outer border (linestyle, linewidth, color).

Return Value

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

Example

Every 50 candles we build a Gann Box from a past swing high down to a recent swing low, with soft background and a few labeled grid levels.

Tips

  • Use swing highs and lows for topPrice and bottomPrice so the box aligns with real market structure.

  • Start simple: [0.25, 0.5, 1] levels often give clear rhythm without clutter.

Warning

  • Do not mix types: times (startTime, endTime) must be time(), prices (topPrice, bottomPrice) must be price values like high() or low().

Good Practice

  • Keep your const style outside repeated logic so you can reuse and adjust easily.

  • Combine Gann Boxes with other confluence tools (like Fib retracements) for stronger signals.

Last updated