Gann Swing System
Attribution: W.D. Gann's swing-charting method - classifying each bar against the prior one as Up, Down, Inside or Outside, and flipping the swing direction only once InpConfirmBars consecutive opposing bars confirm it. This is the same objective classification already used by GannSwingChart.mq4 (Indicators folder, this catalogue), reimplemented here as its own self-contained state machine per house style rather than shared via #include, so this EA can act on the swing structure rather than just plot it. This build deliberately contains none of the cycle-count or astrological material sometimes associated with Gann's name - it is the plain, mechanical swing-reading technique. The trading rule is the classic "1-2-3" swing reversal, built directly from three consecutive CONFIRMED pivots: a bottom is a low, then a high, then a second low that is HIGHER than the first (point 3 above point 1) - the market failed to make a new low, a genuine structural signal that selling pressure is fading. A top is the mirror: high, low, lower high. The entry is a close beyond POINT 2 (the middle pivot) in the pattern's direction, not the extreme itself - Gann-style swing traders wait for the market to actually break the intervening high/low before trusting the reversal. If price instead breaks back through point 3 first, that undoes the higher-low or lower-high the whole pattern depends on, and the setup is cancelled rather than traded. Notes and limitations - Outside bars break the confirmation streak without confirming a reversal themselves - the same discretionary call documented in GannSwingChart.mq4, stated plainly rather than claimed as orthodoxy: Gann's own notes give no single universally agreed rule for how an Outside bar should be treated. - A pattern can arm and later be cancelled (point 3 broken before point 2) without ever generating a trade - this is by design, not a bug; most 1-2-3 shapes that appear on a swing chart do not resolve cleanly. - Only one position at a time; a fresh pattern can still arm while a trade from a previous one is open, but will not fire until flat. - No hardcoded contract size; lot sizing is fixed (InpFixedLots) and normalised to the symbol's MODE_LOTSTEP/MIN/MAXLOT.
Expert advisor · MT4 · v1.0 · Free
About Gann Swing System
Gann Swing System is an expert advisor (trading robot) for MetaTrader 4 based on ATR. It trades breakouts. It has 9 settings, such as Confirm bars, Atr period and Stop buffer atr. MQL source code included.
Files in the download: GannSwingSystem.ex4, GannSwingSystem.mq4, GannSwingSystem.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Confirm bars | 1 | 1 = classic 1-bar swing, 2 = smoother 2-bar swing (see GannSwingChart.mq4) |
| Atr period | 14 | ATR period, used only for the stop buffer beyond point 3 |
| Stop buffer atr | 0.25 | Extra buffer placed beyond point 3 for the stop, ATR multiples |
| Min pattern atr | 1.0 | Minimum point1-to-point2 swing size required, ATR multiples (filters tiny noise patterns) |
| Fixed lots | 0.10 | Fixed lot size |
| Magic number | 20260424 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Order-send attempts before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Pivot Points · Breakout · ATR · MT4 Expert Advisor · MQL4 Source Code