Gann Swing Trading Indicator: Three-Bar Swings, ATR Filtered

Written by Dominic Walsh · Published · Last updated

Gann built his method on swing charts: mark the turning points, then trade the break of one. The gann swing trading indicator does exactly that. It finds three-bar pivots, discards any whose range is too small to matter, and marks the bar whose close takes out the most recent confirmed swing.

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 4: Swing High, Swing Low, BUY, SELL
Alerts popup
Inputs 4

What the Gann Swing Trading Indicator draws on the chart

Swing High marks confirmed pivot highs with a red dot symbol above the bar.

Swing Low marks pivot lows with a lime dot below it.

BUY prints a larger lime arrow where a close clears the last swing high.

SELL prints the red counterpart where a close breaks the last swing low.

  • Swing High: arrow, red, width 2, arrow code 119
  • Swing Low: arrow, lime, width 2, arrow code 119
  • BUY: arrow, lime, width 3, arrow code 233
  • SELL: arrow, red, width 3, arrow code 234
Gann swing trading indicator on EURUSD H1 with ATR-filtered swings and break arrows
Gann swing trading indicator on EURUSD H1 with ATR-filtered swings and break arrows

How the Gann Swing Trading Indicator calculates its values

The three-bar pivot

mid takes i + 1, so the candidate always has a bar either side. midHigh and midLow describe it, with leftHigh and leftLow from mid + 1 and rightHi and rightLo from mid – 1. Comparing the middle bar against both neighbours is the simplest swing definition there is, and Gann’s own swing charts used something very close to it.

Discarding trivial swings

A three-bar turn happens constantly, so most of them mean nothing. topRange measures the spread across the three bars, and atr_ok requires it to exceed `InpAtrMultiplier` times the ATR from iATR over `InpAtrPeriod`. Scaling the filter to volatility means one setting works on a quiet session and a fast one alike.

Trading the break of a swing

Once a swing confirms the code stores lastSwingHigh and lastSwingLow. A buy then needs close[i] above lastSwingHigh while close[i + 1] sat at or below it, so the bar crossed rather than continued. BufBuy lands at low[i] minus twice the offset, which keeps the signal arrow clear of the smaller swing dot.

How to read the signals

Dots mark structure and the larger arrows mark signals. A chart can carry many dots and no arrows.

An arrow always refers back to the most recent confirmed swing, which sits to its left.

Raising the ATR multiplier thins the dots first, and fewer swings then means fewer breaks to trade.

Signal arrows sit further from the candle than swing dots, so the two never overlap.

Alert channels in this build: popup, one message per closed bar.

One channel is present, a terminal popup, driven by `InpEnableAlerts` at its `true` default. Because the break test compares two completed closes, the message follows a settled bar, and the guard permits a single alert per closed bar.

Every Gann Swing Trading Indicator input

Core settings

Setting What it does Default
InpAtrPeriod ATR period for swing filter. Bars in the volatility measure, default `14`. 14
InpAtrMultiplier Swing valid if range > Mult * ATR. How much of an ATR the three-bar range must cover for a swing to count, default `0.5`. This is the main dial: 1.0 leaves only significant turns. 0.5

Display settings

Setting What it does Default
InpArrowOffsetPip Arrow offset (in points). Gap between candle and swing dot, default `5` points. Signal arrows use twice this distance. 5

Alert settings

Setting What it does Default
InpEnableAlerts Push alerts on new BUY/SELL. on
Gann swing trading indicator inputs: InpAtrPeriod and InpAtrMultiplier
Gann swing trading indicator inputs: InpAtrPeriod and InpAtrMultiplier

Settings that fit your chart

Swing breaks work best where price moves in legs rather than grinding. EURUSD H1 is the reference chart. On M5 a three-bar pivot appears constantly and the ATR filter carries the whole load. On H4 and daily each confirmed swing spans real structure, which is closer to how Gann worked, and breaks become genuinely notable events.

When the Gann Swing Trading Indicator fails

A three-bar pivot is the shallowest definition available. Even filtered by ATR it marks turns that a swing trader would not count.

In a range the last confirmed swing sits close to price, so breaks fire in both directions within a few bars.

The filter measures the three-bar range, not the size of the move that followed, so a wide bar cluster passes even when price went nowhere afterwards.

Copy the compiled Gann Swing Trading 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.

Download the Gann Swing Trading Indicator for MT4 and MT5

The zip holds the compiled Gann Swing Trading 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

How strict is the three-bar swing test here?

Not strict at all on its own. mid needs only to beat the bar before and the bar after, which happens throughout any chart. The work is done by the ATR filter that follows: topRange across those three bars must exceed `InpAtrMultiplier` times ATR before the swing is recorded at all.

What happens if I raise InpAtrMultiplier to 1.0?

Far fewer swing dots, and with them far fewer break signals. At the default `0.5` a three-bar range must cover half an average range. At 1.0 it must cover a full one, which on H1 leaves only pronounced turns. That is usually the first adjustment worth trying if the chart looks crowded.

Why do the BUY arrows sit further from the candle than the swing dots?

The code places BufBuy at low[i] minus twice `InpArrowOffsetPip`, while the swing dot uses a single offset. Doubling the distance stops a signal arrow overlapping the pivot marker when both land near the same bar, which happens often in fast conditions.

Does the arrow need a close beyond the swing, or just a touch?

A close. The test needs close[i] beyond lastSwingHigh while close[i + 1] sat on the other side of it. A wick through the level produces nothing. That keeps the signals tied to bars that actually finished past the swing rather than merely probing it.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Gann Swing Trading 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