KG's Gann Pro This indicator that draws Gann-based support/resistance zones, fan lines, and time divisions directly on the price chart.
INPUTS (User Controls):
Parameter Default Purpose Lookback (bars)200How far back to find HH/LL Zone Width %0.8Thickness of S/R boxes Extend Right 60 bars How far lines project into the future Vertical Line Spacing30 bars Gap between time division lines Colors Various Sell, Buy, Pivot, Gann Up/Down, Verticals.
CORE CALCULATIONS:
The script first finds, across the lookback window-
HH = Highest High → its bar index
LL = Lowest Low → its bar index
Range = HH − LL
From the range, three key price levels are derived-
Sell Level = LL + Range × 0.6667 (upper third)
Pivot Level = LL + Range × 0.5000 (midpoint)
Buy Level = LL + Range × 0.3333 (lower third)
THE 6 DRAWING LAYERS:
1. Support/Resistance Zones (Boxes)
Three horizontal colored bands drawn across the entire lookback window-
Red box around the Sell Level → Resistance area
Gray box around the Pivot Level → Neutral/decision zone
Green box around the Buy Level → Support area
Zone thickness is controlled by Zone Width % input.
2. HH & LL Dotted Lines
Two thin dotted lime-colored lines marking the exact Highest High and Lowest Low prices, extending left-to-right across the chart.
3. Orange X Lines (Cross Pattern)
Two diagonal orange lines that form an "X":
Ascending line — starts at the LL bar/price, slopes upward to the right edge
Descending line — starts at the HH bar/price, slopes downward at the same angle
The slope is calculated as: Range ÷ (HH bar − LL bar)
4. Gann Fan Up (from Lowest Low)
9 dashed green lines radiating upward from the Lowest Low point, at these angle multipliers:
8× · 4× · 3× · 2× · 1× · 0.5× · 0.333× · 0.25× · 0.125×
The base unit is Range ÷ bar span between HH and LL. Each line's endpoint = LL + unit × multiplier × bars to right edge.
5. Gann Fan Down (from Highest High)
9 dashed yellow-green lines radiating downward from the Highest High, using the same multipliers but subtracted from HH. Mirror image of the fan up.
6. Vertical Dashed Lines (Time Divisions)
Cyan dashed vertical lines drawn at every N bars (default: 30) across the entire visible range — marking time cycles on the chart.
HOW IT EXECUTES:
All drawing happens only on the last bar (barstate.islast). On every new bar:
All old lines, boxes, and labels are deleted
All arrays are cleared
Everything is redrawn fresh with updated HH/LL values
This keeps the chart clean and prevents object buildup hitting Trading View's limits (500 lines, 60 labels, 30 boxes).
In One Sentence:
It finds the highest high and lowest low over a lookback window, divides the range into Gann-based thirds, draws buy/sell/pivot zones, fans out diagonal lines from both extremes at classical Gann angles, and overlays time-cycle vertical divisions — all refreshed on every bar.
Disclaimer: This indicator is for educational purposes only. Always practice proper risk management and combine with your own analysis before making trading decisions. Happy trading.
Indicador Pine Script®












