The auto harmonic pattern v2 indicator hunts XABCD swing structures on the price chart. It chains confirmed fractal pivots into a zigzag. Each five-pivot window then faces a ratio test, and a valid one ends with a Buy or Sell arrow at point D.
This build ships as auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex4 for MT4 and auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex5 for MT5; the screenshots below come from EURUSD H4.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 3: XABCD, Buy, Sell |
| Alerts | popup, push notification, email, sound |
| Inputs | 16 |
What the Auto Harmonic Pattern V2 Indicator draws on the chart
XABCD names the zigzag plot. It links the alternating fractal highs and lows in dark orange, at width 2. That chain shows the raw swing skeleton even when no pattern qualifies.
Buy and Sell hold the two arrow plots. Buy drops a lime arrow under the low of the completion bar. Sell puts a red arrow above the high. Both sit ArrowOffsetPoints away from the candle, which defaults to 50 points.
Text labels X, A, B, C and D sit on the first valid window. You can trace the legs by eye.
- XABCD: zigzag, dark orange, width 2
- Buy: arrow, lime, width 4, arrow code 233
- Sell: arrow, red, width 4, arrow code 234

How the Auto Harmonic Pattern V2 Indicator calculates its values
Finding the swing pivots
Depth defaults to 7. It sets how many bars on each side must confirm a pivot. A bar counts as a swing high only when every neighbour stays below it. A swing low needs the mirror rule. The scan keeps alternating highs and lows, so two highs in a row collapse into the more extreme one. MaxPivots caps the list at 40 entries.
Testing the XABCD leg ratios
Each window of five pivots gives four legs. The code measures XA, AB, BC and CD as absolute price distances. Three ratios follow: AB over XA, BC over AB, and CD over BC. Ratio thinking here mirrors Fibonacci retracement work, though nothing draws those levels for you.
AbLo defaults to 0.35 and AbHi to 0.55. The AB leg therefore gives back a third to a half of XA. BcLo defaults to 0.3 and BcHi to 0.9. CdLo defaults to 1.6 and CdHi to 2.65, which makes CD the long extension leg. RatioTol widens each band by 0.12 in both directions.
Marking the completion bar
A window that clears all three tests prints a signal at pivot D. When D sits on a swing low, the shape reads bullish. Buy then takes the bar low minus the offset. A swing high at D sends the bar high plus the offset into Sell. Only the newest valid window earns the X to D text labels.
How to read the signals
Treat point D as the trigger, not the whole trade. The zigzag leg running into D shows the swing the shape expects to fail. Your invalidation level sits just beyond it.
A lime Buy under a bar says the code found a bullish XABCD ending on a swing low. Price often reacts back toward C or B after a completion. Many traders scale out near those pivots. The arrow itself carries no target.
Watch the XABCD line for context. A shallow, choppy chain means the pivots came from noise rather than structure. Any shape built on it deserves less weight.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
EnableAlerts gates the block and ships on, together with EnablePopup. EnablePushNotify, EnableEmail and EnableSound stay off until you turn them on. The dispatcher scans the last three bars once per new bar, so one completion sends one message.
Every Auto Harmonic Pattern V2 Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
Depth |
Fractal width in bars each side; the shipped value keeps pivots meaningful on H4, and 3 suits faster charts. | 7 |
MaxPivots |
How many alternating swings the scan holds; the code hard limits the list to 60 whatever you enter. | 40 |
AbLo |
Floor for the AB over XA ratio; drop it to catch shallower retracement legs. | 0.35 |
AbHi |
Ceiling for the same ratio; raise it when your market retraces deeper than half of XA. | 0.55 |
BcLo |
Floor for BC over AB; a low floor lets brief pullbacks inside the pattern qualify. | 0.3 |
BcHi |
Ceiling for BC over AB; tighten it to reject windows where C almost erases the AB leg. | 0.9 |
CdLo |
Floor for CD over BC; this is the extension test that defines the completion leg. | 1.6 |
CdHi |
Ceiling for CD over BC; lower it to stop runaway final legs from counting. | 2.65 |
RatioTol |
Slack added to every band on both sides; raise it for looser shapes, cut it toward zero for strict ones. | 0.12 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPoints |
Gap in points between the marker and the candle; lift it on gold or indices with longer wicks. | 50 |
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 |

Settings that fit your chart
Give the scan room. The EURUSD H4 chart in the screenshot spaces its swings far enough apart for the ratio bands to mean something. Majors and gold with steady ranges suit the test better than thin exotics. On a thin symbol one spike can define a swing. Lower timeframes still work, though you want a larger Depth setting there.
When the Auto Harmonic Pattern V2 Indicator fails
Ratio bands reject far more windows than they accept. On a quiet range the scan can go weeks without a completion. That silence is normal rather than a fault.
Pivot detection needs bars on the right of a candle before it counts. A completion therefore appears several bars after the fact. The D arrow lands on a candle that has already passed.
Harmonic ratios describe geometry, not order flow. A textbook XABCD can complete straight into a news release and unwind in one candle. The marker needs support from your own levels.
Widening the tolerance lets more shapes through, but each extra match dilutes the idea. Tighten it again if the chart fills with completions you would not have traded.
Copy auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex4 into MQL4/Indicators and auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex5 into MQL5/Indicators, then restart the terminal and drag the Auto Harmonic Pattern V2 Indicator onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Auto Harmonic Pattern V2 Indicator for MT4 and MT5
The zip auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.zip holds auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex4, auto-harmonic-pattern-v2-indicator-indicator-forexmt4systems.ex5 and a short README, compiled files only. 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
How far back does MaxPivots let the scan look?
MaxPivots caps the pivot list at 40 alternating swings. The code hard limits it to 60 whatever you type. That window covers a long stretch of an H4 chart. It also stops the loop from crawling on a symbol with tens of thousands of bars. Lower it when you only care about recent structure.
Why does the XABCD line appear without any arrows?
The zigzag draws on every confirmed pivot, whether or not a shape qualifies. Markers only print when the AB, BC and CD ratios all land inside their bands. So a busy XABCD chain with no arrows tells you the swings exist. Their proportions miss the harmonic template by too much.
Can I loosen the ratio bands with RatioTol?
Yes. RatioTol adds 0.12 to each side of every band. An AB reading of 0.30 still clears a 0.35 floor. Raise it and the scan accepts looser geometry, which brings more completions and more marginal ones. Cut it toward zero when you want strict textbook shapes only.
Which chart suits the scan, and does EURUSD H4 work well?
Pivot geometry reads best where swings separate cleanly. The EURUSD H4 chart in the screenshot gives that spacing. Majors and gold on H1 or higher usually leave enough room between fractals. On M5 the same depth turns small wiggles into pivots, so raise it before you trust the output.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Auto Harmonic Pattern V2 Indicator as one input. Always backtest before trading live.
Category: this is part of our Support and Resistance collection. Also, still, hence, plainly, truly, browse more Support and Resistance for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- For background on this concept, see Candlestick pattern on Wikipedia.
- For broader market context, see Candlesticks And Resistance at StockCharts ChartSchool.
