The harmonic pattern detection indicator works from a pivot list. Five entries give four legs. Each pattern spec carries its own ratio bands. When no five-pivot shape fits, a fallback marks simpler three-pivot turns.
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, Harmonic SELL |
| Alerts | popup |
| Inputs | 8 |
What the Harmonic Pattern Detection Indicator draws on the chart
`Harmonic BUY` uses arrow 233 and `Harmonic SELL` uses 234.
`InpDrawLines` adds trend objects for the XA, AB, BC and CD legs.
Text objects name the matched pattern at point D.
Marks sit `InpArrowOffsetPts` `30` points from the candle.
- Harmonic BUY: arrow, lime, width 2, arrow code 233
- Harmonic SELL: arrow, red, width 2, arrow code 234

How the Harmonic Pattern Detection Indicator calculates its values
Pivots then legs
`InpZigZagDepth` `3` builds the pivot list, and consecutive pivots must alternate between high and low. Five of them give the four leg lengths the ratio test needs.
Several specs, one tolerance
Each spec carries its own target for AB against XA. It also holds a range for BC against AB and a check on AD against XA. `InpFibTolerance` `0.30` widens every one of them, which is loose by harmonic standards.
The fallback matters
`InpFallbackOnEmpty` `true` means an empty search still produces marks. Three pivots forming a turn qualify instead. Those marks carry no ratio evidence, so they are a different signal wearing the same arrow.
How to read the signals
A labelled mark came from a real five-pivot match.
An unlabelled mark most likely came from the fallback.
`InpMaxPatterns` `6` caps how many shapes stay on the chart.
`InpMaxPatternBars` `500` bounds how far X can sit from D.
Alert channels in this build: popup.
One route ships here. `InpEnableAlerts` starts true and raises a terminal message at point D. The bar has to close first. No mobile, mail or sound option exists, so watch the alerts tab.
Every Harmonic Pattern Detection Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
InpZigZagDepth |
ZigZag pivot depth (bars). Bars either side that confirm a pivot, default `3`. | 3 |
InpFibTolerance |
Loose fib ratio tolerance. Slack applied to every ratio band, default `0.30`. | 0.30 |
InpMaxPatternBars |
Max X..D span (bars). Widest span from X to D, in bars, default `500`. | 500 |
InpMaxPatterns |
Max patterns to mark. How many shapes stay marked, default `6`. | 6 |
InpFallbackOnEmpty |
If no XABCD found, mark 3-pivot reversals. Mark three-pivot turns when no shape matches, default `true`. | on |
Display settings
| Setting | What it does | Default |
|---|---|---|
InpArrowOffsetPts |
Arrow offset (points). Points between the mark and the candle, default `30`. | 30 |
InpDrawLines |
Draw XA, AB, BC, CD trend lines. Draw the four leg lines, default `true`. | on |
Alert settings
| Setting | What it does | Default |
|---|---|---|
InpEnableAlerts |
Bar-close alerts on D. Bar-close alert at point D, default `true`. | on |

Settings that fit your chart
A three-bar pivot finds far more swings than a deep fractal. EURUSD H1 is the reference chart, where `InpMaxPatternBars` `500` reaches back three weeks. On M15 the pivot list churns. H4 gives sturdier shapes.
When the Harmonic Pattern Detection Indicator fails
`InpFibTolerance` `0.30` is wide enough that quite loose shapes still qualify.
The fallback marks turns with no ratio behind them. That blurs what an arrow means.
A three-bar pivot is shallow, so the pivot list contains plenty of noise.
Copy the compiled Harmonic Pattern Detection 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 Detection Indicator: Acquisition of Credit Suisse by UBS on Wikipedia, Cvr3 Vix Market Timing at StockCharts ChartSchool.
Download the Harmonic Pattern Detection Indicator for MT4 and MT5
The zip holds the compiled Harmonic Pattern Detection 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.
FAQ
What does InpZigZagDepth 3 confirm?
A pivot with three bars on each side. That is shallow, so the list fills with small turns as well as major ones. Raise it for fewer, cleaner pivots. Fewer candidate patterns follow from that.
How loose is InpFibTolerance 0.30?
Very. Thirty hundredths of slack on every band lets shapes through that a strict reading would reject. Tighten it toward 0.10 if you want matches that look like the textbook diagrams.
What does InpFallbackOnEmpty change?
Whether an empty search still marks something. With it true, three pivots forming a turn get an arrow even though no ratio matched. Set it false and every mark then carries real ratio evidence.
Why does InpMaxPatterns 6 exist?
To cap chart clutter. Six shapes plus leg lines and labels already fill a screen. Without the limit a long history would leave the terminal drawing hundreds of objects for no gain.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Harmonic Pattern Detection Indicator as one input. Always backtest before trading live.
Category: this is part of our Support and Resistance collection. Next, plainly, browse more Support and Resistance for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- Learn more about the underlying method in Acquisition of Credit Suisse by UBS on Wikipedia.
- For wider market background, see Cvr3 Vix Market Timing at StockCharts ChartSchool.
