Legacy of Gann Indicator: One Line That Follows the Last Swing

Written by Dominic Walsh · Published · Last updated

The legacy of gann indicator draws one line and nothing else. It watches for a run of consecutive higher highs or lower lows, and when a run completes it flips direction and locks onto the pivot from the far side of that run. The line then holds flat until the opposite run appears. It is the swing-chart idea reduced to a single trailing level.

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 1: Gann Swing
Alerts popup, push notification, email, sound
Inputs 7

What the build shows

Gann Swing is the one plot, a lime green line holding the current pivot level.

The line steps rather than curves, because it only moves when direction flips.

Nothing else appears. There are no markers, zones, labels or shading of any kind.

Between flips the level stays exactly where it was set.

  • Gann Swing: plot, lime green
Legacy of Gann indicator on EURUSD H1 with the stepped swing pivot line
Legacy of Gann indicator on EURUSD H1 with the stepped swing pivot line

The mechanism

Looking for an unbroken run

up_run starts true and survives only while every bar in the window makes a higher high than the one before it, checked as high[i – k] against high[i – k – 1]. dn_run applies the mirror test to lows. `SwingBars` at `4` sets the run length, so four consecutive steps in one direction are needed.

Flipping and setting the pivot

A completed up_run flips dir to 1 and sets pivot to low[i – SwingBars], the low at the far end of the run. A completed dn_run flips dir to minus 1 and takes high[i – SwingBars]. Taking the opposite extreme of the run is what makes the level a trailing reference rather than a trend line.

Holding until the next flip

SwingBuf[i] receives pivot on every bar, whether or not it changed. That is why the plot runs flat between flips. The alert check then compares two settled bars: close[latest – 2] against its own SwingBuf value and close[latest – 1] against the next, so a message follows price crossing the held level.

How to take a reading

A flat stretch is the normal state. The line only steps when a run completes.

The level sits at the opposite extreme of the run that set it, so it usually trails price.

Price crossing the line is the event worth watching, since the line itself gives no direction.

Long runs are rare, which is why the level can hold for a long time on slower charts.

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

Four channels sit beneath `EnableAlerts`: popup, push notification, email and sound, with `SoundFile` naming the clip. Popup ships enabled. The check reads two settled bars rather than the forming one, and the guard permits a single message per closed bar.

Every Legacy of Gann Indicator input

Core settings

Setting What it does Default
SwingBars Consecutive higher highs or lower lows needed before direction flips, default `4`. This is the only calculation input. Raising it to 6 makes flips rare and the level very sticky. 4

Alert settings

Setting What it does Default
EnableAlerts (see inputs panel) on
EnablePopup (see inputs panel) on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile (see inputs panel) alert.wav
Legacy of Gann indicator inputs panel: SwingBars plus the alert switches
Legacy of Gann indicator inputs panel: SwingBars plus the alert switches

Matching it to your chart

A four-bar run is a demanding condition on any chart, so this works wherever price moves in clean legs. EURUSD H1 is the reference, where flips happen a few times a week. On M5 runs complete more often and the line steps regularly. On the daily chart a four-bar run of higher highs is uncommon enough that the level can hold for weeks.

Where it stops working

One input and no filter means no way to tune the level to an instrument’s volatility.

A run needs strictly consecutive steps, so a single inside bar breaks it and a strong move can pass without flipping the line.

Because the pivot comes from the far end of the run, the level can sit a long way from price after a fast move.

Copy the compiled Legacy of Gann 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 Legacy of Gann Indicator: Frictionless market on Wikipedia, Stock Market Cycles at StockCharts ChartSchool.

Download the Legacy of Gann Indicator for MT4 and MT5

The zip holds the compiled Legacy of Gann 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 exactly does SwingBars at 4 require?

Four consecutive bars each making a higher high than the one before, with no exception. The loop clears up_run the moment high[i – k] fails to beat high[i – k – 1]. One inside bar in the middle of an otherwise strong move breaks the run entirely, which is why flips are less frequent than the number suggests.

Where does the Gann Swing level actually sit?

At the opposite extreme of the run that set it. An up_run flips direction upward and takes low[i – SwingBars], the low from the far end of that run. That places the level below price after a bullish flip, so it works as a trailing reference rather than a line drawn through the swings.

Why does the Gann Swing line run flat for so long?

Because SwingBuf receives the same pivot on every bar until a new run completes. The level does not drift, decay or track price. Flat is the normal state, and a step in the line means a genuine flip just happened.

Does anything besides the Gann Swing line mark the flips?

No. This build declares a single plot and nothing else, so there are no markers, labels or shading. The step in the line is the only visual event. Traders who want markers usually pair it with a separate signal tool rather than expecting them here.

Are results guaranteed?

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

Category: this is part of our Volatility collection. Next, plainly, yet, browse more Volatility 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