Harmonic Pattern Finder Indicator: A ZigZag Then Ratios

Written by Dominic Walsh · Published · Last updated

The harmonic pattern finder indicator adds a size filter. A swing must clear `ZzDeviationPts` `5` points to join the pivot list. Ratio testing then runs over what is left.

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: Buy, Sell
Alerts popup, push notification, email, sound
Inputs 21

What the Harmonic Pattern Finder Indicator draws on the chart

`Buy` and `Sell` use whatever codes `BuyArrowCode` `233` and `SellArrowCode` `234` hold.

`DrawXABCD` adds trend objects in `ColorBullPattern` or `ColorBearPattern`.

`LabelAtD` places a text object naming the shape at point D.

Marks sit `ArrowOffsetPts` `30.0` points from the wick.

  • Buy: arrow, lime, width 2, arrow code BuyArrowCode
  • Sell: arrow, red, width 2, arrow code SellArrowCode
Harmonic pattern finder indicator leg lines and pattern arrows on the EURUSD H1 chart.
Harmonic pattern finder indicator leg lines and pattern arrows on the EURUSD H1 chart.

How the Harmonic Pattern Finder Indicator calculates its values

Three filters build the pivot list

`PivotDepth` `3` runs the strict high and low test. `ZzDeviationPts` `5` throws out swings too small to matter. `ZzBackstep` `2` keeps successive pivots from sitting on top of each other.

Ratios across four legs

The code measures AB against XA, BC against AB, then checks D against XA or against BC. Matching either of those last two is enough. `HarmonicTolerance` `0.30` widens every comparison.

Bounded search

`MaxLookbackBars` `500` limits how much history the scan covers. `MaxPivotsScanned` `30` limits how many recent pivots it tries. Both keep the work small enough for every tick.

How to read the signals

A bullish shape ends on a swing low, which fills the buy plot.

`PatternLineWidth` `2` controls how heavy the leg lines look.

`EnableFallback` `true` allows three-pivot marks when no shape matches.

Colours separate bullish from bearish shapes at a glance.

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

`EnableAlerts` sits above four routes and ships true beside `EnablePopup`. Flip `EnablePushNotify` for a phone message, `EnableEmail` for mail, or `EnableSound` to sound `SoundFile`. Those three start off. Bars close before anything sends.

Every Harmonic Pattern Finder Indicator input

Core settings

Setting What it does Default
PivotDepth lookback bars for strict pivot test. Bars either side for the strict pivot test, default `3`. 3
ZzDeviationPts swing minimum size in points. Smallest swing the list keeps, in points, default `5`. 5
ZzBackstep bars between successive pivots. Bars between two pivots, default `2`. 2
HarmonicTolerance ratio match tolerance (Fibonacci 0.30). Slack on each ratio check, default `0.30`. 0.30
MaxLookbackBars most-recent bars scanned for XABCD. Recent bars the scan covers, default `500`. 500
MaxPivotsScanned recent pivots considered for XABCD assembly. Recent pivots it tries, default `30`. 30
EnableFallback 3-pivot reversal arrows when no XABCD. Allow three-pivot marks when nothing fits, default `true`. on

Display settings

Setting What it does Default
DrawXABCD draw XA AB BC CD trendlines. Draw the four leg lines, default `true`. on
LabelAtD place pattern label at point D. Name the shape at point D, default `true`. on
ColorBullPattern (see inputs panel) dodger blue
ColorBearPattern (see inputs panel) orange red
PatternLineWidth (see inputs panel) 2
BuyArrowCode Wingding code for the buy mark, default `233`. 233
SellArrowCode Wingding code for the sell mark, default `234`. 234
ArrowOffsetPts arrow offset in points from candle wick. Points from the wick to the mark, default `30.0`. 30.0

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
Harmonic pattern finder indicator inputs panel with PivotDepth, ZzDeviationPts and HarmonicTolerance.
Harmonic pattern finder indicator inputs panel with PivotDepth, ZzDeviationPts and HarmonicTolerance.

Settings that fit your chart

A points-based filter behaves differently per symbol. EURUSD H1 is the reference chart, where five points is a small swing. On a gold chart that figure filters almost nothing. Scale it with the instrument.

When the Harmonic Pattern Finder Indicator fails

`ZzDeviationPts` `5` counts in points, so each symbol needs its own value.

The D test passes on either of two ratios, which is looser than one strict rule.

Three-pivot fallback marks share the same arrow as real matches.

Copy the compiled Harmonic Pattern Finder 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 Harmonic Pattern Finder Indicator: Algorithmic trading on Wikipedia, Hindenburg Omen at StockCharts ChartSchool.

Download the Harmonic Pattern Finder Indicator for MT4 and MT5

The zip holds the compiled Harmonic Pattern Finder 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 ZzDeviationPts 5 remove?

Swings smaller than five points. That keeps tiny wiggles out of the pivot list. It is the main difference between this build and a depth-only pivot finder. Points scale with the symbol, so review the value each time.

Why does ZzBackstep 2 matter?

It stops two pivots forming within two bars. Without that spacing the list fills with near-duplicate points. Leg lengths behind every ratio then turn unreliable.

Can I change BuyArrowCode?

Yes. It takes any Wingdings code, and `233` is the usual up arrow. Some traders prefer a dot or a triangle. That is why the code sits in the inputs rather than the source.

What does MaxPivotsScanned 30 bound?

How many recent pivots it tries as five-point candidates. Thirty gives a workable number of combinations. Raising it finds older shapes and costs more work on every tick.

Are results guaranteed?

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

Category: this is part of our Candle Sticks collection. Also, truly, browse more Candle Sticks 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