Gann Square Indicator: A Box Padded By Percentages

Written by Dominic Walsh · Published · Last updated

The gann square indicator frames a swing pair in a box, then pads it. `TopOffsetPct` multiplies the swing high and `BotOffsetPct` multiplies the swing low, so the edges sit slightly outside the prices they came from. A gold midline splits the result in half.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 2: Gann Swing High, Gann Swing Low
Alerts popup, push notification, email, sound
Inputs 15

What the Gann Square Indicator draws on the chart

Gann Swing High marks a confirmed pivot high and Gann Swing Low marks a pivot low.

An OBJ_RECTANGLE frames the padded box in `BoxColor`.

An OBJ_TREND midline draws in `CenterColor` at the halfway price.

OBJ_TEXT labels name the edges when the box is drawn.

  • Gann Swing High: arrow, lime, arrow code 234
  • Gann Swing Low: arrow, red, arrow code 233
Gann square indicator on EURUSD H1 with the padded swing box and midline
Gann square indicator on EURUSD H1 with the padded swing box and midline

How the Gann Square Indicator calculates its values

Collecting the swings

A pivot needs `SwingBars` `12` bars on each side that fail to beat it. The scan reaches back `LookbackBars` `400` bars and keeps up to two highs and two lows. The most extreme of each pair sets the box.

Padding the edges

topEdge takes the swing high times `TopOffsetPct` `1.01`, so the box sits one percent above it. botEdge takes the swing low times `BotOffsetPct` `0.99`. Multiplying rather than adding means the pad scales with price.

Splitting it

mid takes the two edges and halves the distance. The alert then compares the last two closes against that midline. So the box is drawing and the midline is the only thing the code watches.

How to read the signals

The box edges sit outside the swings, not on them.

A one percent pad is large on gold and small on a currency pair.

The gold midline is the level the alert watches.

A fresh pivot inside the lookback redraws the whole box.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Four channels hang off `EnableAlerts`, which starts on, with `EnablePopup` joining it. `EnablePushNotify`, `EnableEmail` and `EnableSound` stay false until you change them. `SoundFile` picks the clip. The midline test reads two closes.

Every Gann Square Indicator input

Core settings

Setting What it does Default
SwingBars bars on each side to qualify as a pivot. Bars each side of a pivot, default `12`. 12
LookbackBars how far back to scan for pivots. Bars scanned for pivots, default `400`. 400
TopOffsetPct top edge multiplier on swing high. Multiplier on the swing high, default `1.01`. 1.01
BotOffsetPct bottom edge multiplier on swing low. Multiplier on the swing low, default `0.99`. 0.99
ObjPrefix Prefix on every object name, default `GannSq_`. GannSq_

Display settings

Setting What it does Default
BoxColor Box outline colour, default dodger blue. dodger blue
CenterColor Midline colour, default gold. gold
BoxWidth Box line width, default `2`. 2
CenterWidth (see inputs panel) 1

Alert settings

Setting What it does Default
EnableAlerts Master switch for the box midline alerts, default `true`. on
EnablePopup Terminal dialog when price crosses the midline, default `true`. on
EnablePushNotify Phone push on that crossing, default `false`. off
EnableEmail Mail delivery on that crossing, default `false`. off
EnableSound Sound playback on that crossing, default `false`. off
SoundFile Wav clip for the box alert, default `alert.wav`. alert.wav
Gann square indicator inputs: SwingBars, LookbackBars, TopOffsetPct, BotOffsetPct
Gann square indicator inputs: SwingBars, LookbackBars, TopOffsetPct, BotOffsetPct

Settings that fit your chart

A twelve-bar pivot is demanding, so the box changes rarely. EURUSD H1 is the reference chart, where `LookbackBars` at `400` covers over two weeks. On M5 the same span is a day and a half. On H4 the box can frame a month of trade.

When the Gann Square Indicator fails

A percentage pad behaves very differently across instruments, since it scales with price.

The box rests on two pivots, so one new extreme moves everything.

`SwingBars` `12` confirms late, meaning the swings are always at least twelve bars old.

Copy the compiled Gann Square Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Background reading on the method behind the Gann Square Indicator: Special drawing rights on Wikipedia, Distance To Highs at StockCharts ChartSchool.

Download the Gann Square Indicator for MT4 and MT5

The zip holds the compiled Gann Square Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What does TopOffsetPct at 1.01 do?

It multiplies the swing high by 1.01, putting the box edge one percent above it. On EURUSD near 1.09 that is about 110 pips. On gold near 2400 it is 24 dollars, which is a very different pad.

Why does TopOffsetPct multiply rather than add?

So the pad scales with price. A fixed point offset that suits a currency pair disappears on an index. Multiplying keeps the box proportional, though it does mean the pad varies a lot between instruments.

What does the CenterColor midline trigger?

A crossing. Two completed closes get compared against the gold midline, and the message fires when price moves through it. Box edges and swing markers stay silent, so this is the only level the code watches.

How demanding is SwingBars at 12?

Very. A pivot must beat every bar within twelve positions on both sides, which on EURUSD H1 means half a day either way. That keeps the box anchored to genuinely large turns, at the cost of confirming late.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Gann Square Indicator as one input. Always backtest before trading live.

Category: this is part of our Signal and Forecast collection. Also, truly, browse more Signal and Forecast for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment