All Harmonic Patterns Scanner Indicator: Gartley to Crab

Written by Dominic Walsh · Published · Last updated

The all harmonic patterns scanner indicator finds five point XABCD structures and names the ones that fit a known ratio set. It tests each completed structure against Gartley, Bat, Butterfly and Crab. When a match lands it draws the outline, writes the pattern name on the chart and puts an arrow at point D.

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: Harmonic BUY (bullish D), Harmonic SELL (bearish D)
Alerts popup, push notification, email, sound
Inputs 16

What the All Harmonic Patterns Scanner Indicator draws on the chart

Harmonic BUY (bullish D) puts a lime arrow under point D when D marks a swing low.

Harmonic SELL (bearish D) puts a red arrow above D when D marks a swing high.

Trend line objects join X, A, B, C and D into the pattern outline.

A text object names the matched pattern beside the structure, in LabelColor at LabelFontSize.

  • Harmonic BUY (bullish D): arrow, width 2, arrow code 233
  • Harmonic SELL (bearish D): arrow, width 2, arrow code 234
EURUSD H1: the all harmonic patterns scanner indicator drawing an XABCD outline with a Harmonic BUY arrow.
EURUSD H1: the all harmonic patterns scanner indicator drawing an XABCD outline with a Harmonic BUY arrow.

How the All Harmonic Patterns Scanner Indicator calculates its values

Finding the pivots

A fractal style scan does the pivot work. A bar counts as a swing high only when its high beats every bar in the LeftBars window behind it and the RightBars window in front of it.

The code collapses two same type pivots in a row into the more extreme one. What remains alternates high, low, high, low all the way back through the history scanned.

Testing the ratios

The five newest alternating pivots become X, A, B, C and D, with D the newest. Because the sequence alternates, X and D always share a type, so a low at D makes the structure bullish.

The code measures legs as absolute price moves and compares them against the ratio set for each named pattern. Tolerance sets the band either side of every target ratio.

Why a confirmed pivot does not move

The scan accepts a pivot only once RightBars closed bars sit to the right of it. Until then the code will not treat that bar as a swing point at all.

That costs you bars. In return, a pattern already on the chart does not vanish when the next candle prints a new extreme.

How to read the signals

The text label names which of the four patterns matched, and the geometry behind them differs even where the drawings look similar.

An arrow marks point D, where the ratio set completes. It gives you no forecast of the next bar.

MaxPatternsShown limits how many outlines stay visible, so older matches drop off as new ones appear.

Nothing can appear on the newest RightBars candles, since the scan has not confirmed those pivots yet.

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

Alerts run through popup, push, email and sound when a pattern completes. A bar time check limits the tool to one alert per closed bar.

Every All Harmonic Patterns Scanner Indicator input

Core settings

Setting What it does Default
LeftBars Fractal bars to the left of a pivot. LeftBars is how many older bars a pivot has to beat. It defaults to 12. Larger values find fewer and bigger swings. 12
RightBars Confirmed bars to the right of a pivot. RightBars is the confirmation window in front of a pivot, 12 by default. It sets how long the scan waits before accepting a swing. 12
Tolerance +/- band on point-target ratios. Tolerance is the band either side of each target ratio, 0.09 by default. Widening it matches more structures and loosens what counts as a pattern. 0.09
MaxPatternsShown Newest patterns drawn with lines. MaxPatternsShown caps how many outlines appear at once, at 3 by default. 3

Display settings

Setting What it does Default
ArrowOffsetPts Arrow offset from the D bar (points). ArrowOffsetPts sets the gap between the arrow and the D bar, 45 points by default. 45
BuyColor Bullish D arrow / outline. lime
SellColor Bearish D arrow / outline. red
LabelColor Pattern name colour. gold
LabelFontSize Pattern name font size. LabelFontSize sets the size of the pattern name text, 9 by default. 9

Alert settings

Setting What it does Default
MaxBars History bars to scan (0 = all). MaxBars limits how much history the scan covers. It defaults to 1500, and 0 means the whole chart. 1500
EnableAlerts Master alert switch. on
EnablePopup Popup alert. on
EnablePushNotify Push notification to mobile. off
EnableEmail Email alert. off
EnableSound Sound alert. off
SoundFile Sound file. alert.wav
Inputs panel for the all harmonic patterns scanner indicator with LeftBars, RightBars and Tolerance.
Inputs panel for the all harmonic patterns scanner indicator with LeftBars, RightBars and Tolerance.

Settings that fit your chart

The screenshot uses EURUSD H1. This geometry needs swings with room in them, so H1 and above give the pivot scan something to work with. On M1 and M5 the fractal window fills with noise and matched structures pile up. Raising LeftBars and RightBars together is the usual answer on a fast chart.

When the All Harmonic Patterns Scanner Indicator fails

The structure only completes at D, which is after the C to D leg has already run. There is no early warning built into the geometry.

A wide Tolerance turns near misses into matches. At 0.09 the ratio bands are already generous, and widening them further makes the labels less meaningful.

Confirmation costs bars. Nothing prints on the newest RightBars candles, so an arrow arrives at least that many bars after the pivot it marks.

The scan only tests the five newest alternating pivots. An older structure that would have matched drops out once a newer pivot moves it beyond that window.

Copy the compiled All Harmonic Patterns Scanner 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 All Harmonic Patterns Scanner Indicator: Financial instrument on Wikipedia, Triple Exponential Moving Average TEMA at StockCharts ChartSchool.

Download the All Harmonic Patterns Scanner Indicator for MT4 and MT5

The zip holds the compiled All Harmonic Patterns Scanner 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

Which four harmonic patterns does the scanner test for?

It checks Gartley, Bat, Butterfly and Crab. Each carries its own set of Fibonacci ratio targets for the XABCD legs. The scan measures those legs as absolute price moves and compares them against every set, so a structure only gets a label once it fits one specific pattern.

How long does RightBars 12 delay a confirmed pivot?

Twelve closed bars. The scan holds a swing point back until that many candles have printed to its right without beating it. So the earliest a Harmonic BUY arrow can appear is twelve bars after the low it actually marks.

What does Tolerance at 0.09 allow in the ratio checks?

Every target ratio gets a band of plus or minus 0.09 around it. A leg landing inside that band counts as a match. Tightening Tolerance towards 0.05 makes the scan strict and finds far fewer structures. Widening it past 0.12 starts labelling shapes that barely resemble the pattern.

Why do older pattern outlines disappear from the chart?

MaxPatternsShown caps how many appear, at 3 by default. When a newer structure completes, the code removes the oldest outline and its label to make room. Raise the value if you want more history visible, at the cost of a busier chart.

Are results guaranteed?

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

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