The ctrader harmonic pattern indicator scans price swings for four harmonic shapes: Gartley, Bat, Butterfly and Crab. It finds five pivot points and calls them X, A, B, C, D. It checks the leg ratios between those points against the known ratio for each pattern. A match inside RatioTol gets marked on the chart. It suits traders who already read harmonic patterns and want the ratio math checked for them.
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 | 3: XABCD, Buy, Sell |
| Alerts | popup, push notification, email, sound |
| Inputs | 14 |
What the Ctrader Harmonic Pattern Indicator draws on the chart
XABCD draws a deep-sky-blue zigzag line connecting the five pivots of a detected pattern.
Buy prints a lime arrow (code 233) and Sell a red arrow (code 234) at a completed bullish or bearish pattern.
A text label names which pattern, Gartley, Bat, Butterfly or Crab, matched.
- XABCD: zigzag, deep sky blue, width 2
- Buy: arrow, lime, width 4, arrow code 233
- Sell: arrow, red, width 4, arrow code 234

How the Ctrader Harmonic Pattern Indicator calculates its values
Fractal pivots feed the pattern search
PivotDepth sets how many bars must confirm a fractal high or low; the default is `5`. MaxPivots caps how many pivots the scan keeps in memory; the default is `50`. The code needs five pivots in a row to test a shape.
Ratio test against each pattern
The code measures the XA, AB, BC and AD legs between the five pivots. It turns each leg into a ratio: AB against XA, BC against AB, AD against XA.
Each of the four toggles sets its own target ratios. Gartley looks for AB near 0.618 and AD near 0.786. Bat looks for AB near 0.50 and AD near 0.886. Butterfly looks for AB near 0.786 and AD near 1.27. Crab looks for AB between 0.382 and 0.618, and AD near 1.618.
RatioTol sets how far a measured ratio may drift from that target and still count; the default is `0.10`. Anything outside that gap gets rejected.
How to read the signals
The XABCD zigzag line traces the five pivots the code used to measure the pattern.
A Buy or Sell arrow prints once the D point completes and the ratios match one of the enabled patterns within RatioTol.
The text label next to the pattern names which of Gartley, Bat, Butterfly or Crab matched.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
Alerts cover popup, push, email and sound, and fire once per closed bar.
Every Ctrader Harmonic Pattern Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
PivotDepth |
ZigZag pivot detection depth. Bars needed to confirm a fractal pivot on each side; default `5`. | 5 |
MaxPivots |
Max alternating pivots to scan. Maximum alternating pivots kept in memory for the scan; default `50`. | 50 |
RatioTol |
Fibonacci ratio tolerance (+/-). Allowed tolerance around each pattern’s published ratio; default `0.10`. | 0.10 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPoints |
Arrow vertical offset (points). | 40 |
ShowGartley |
Detect Gartley (AB=0.618, AD=0.786). Toggles Gartley matching, AB 0.618 and AD 0.786; on by default. | on |
ShowBat |
Detect Bat (AB=0.50, AD=0.886). Toggles Bat matching, AB 0.50 and AD 0.886; on by default. | on |
ShowButterfly |
Detect Butterfly (AB=0.786, AD=1.27). Toggles Butterfly matching, AB 0.786 and AD 1.27; on by default. | on |
ShowCrab |
Detect Crab (AB=0.382-0.618, AD=1.618). Toggles Crab matching, AB 0.382 to 0.618 and AD 1.618; on by default. | on |
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
Harmonic patterns need enough swing structure to form cleanly; the build notes and the screenshot below both use EURUSD H1 for that reason.
When the Ctrader Harmonic Pattern Indicator fails
RatioTol of `0.10` is fairly wide. On a choppy pair the scan can mark a shape whose ratios are only loosely harmonic, not textbook-clean.
MaxPivots limits how far back the scan can look. On a slow chart it can take a long stretch of bars before five usable pivots build up.
All four patterns share the same PivotDepth and RatioTol. Widen the tolerance to catch more Crab matches, and Gartley, Bat and Butterfly get looser too.
The scan only tests shape and ratio. It does not check trend context or volume, so a pattern can complete inside a wider move that ignores it entirely.
Copy the compiled Ctrader Harmonic Pattern 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 Ctrader Harmonic Pattern Indicator: Cross-currency swap on Wikipedia, Leadingindicator at Investopedia.
Download the Ctrader Harmonic Pattern Indicator for MT4 and MT5
The zip holds the compiled Ctrader Harmonic Pattern 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
Which harmonic patterns does this scan for?
Four patterns: Gartley, Bat, Butterfly and Crab. Each has its own on/off toggle (ShowGartley, ShowBat, ShowButterfly, ShowCrab) and its own AB and AD ratio pair, taken from the source code comments.
What does RatioTol control?
RatioTol sets how far a measured leg ratio may sit from the pattern’s target ratio and still count as a match. The default is `0.10`. Lower it for a tighter, more textbook-accurate match.
How does the code find the pivots for the XABCD shape?
It uses fractal highs and lows, confirmed by PivotDepth bars on each side. MaxPivots caps how many of those pivots the scan keeps ready while it searches for a five-point match.
Does the indicator only work on EURUSD?
No. The build notes and screenshot use EURUSD H1 because that pair gives the pattern search enough swing structure. The same fractal and ratio logic runs on any instrument.
Does a wider RatioTol mean more signals or better signals?
More, not better. A wider RatioTol lets looser, less textbook-accurate ratios pass the test, so the code marks more shapes but each one is a weaker match to the true pattern.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Ctrader Harmonic Pattern Indicator as one input. Always backtest before trading live.
Category: this is part of our Support and Resistance collection. Then, plainly, browse more Support and Resistance for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- The core method is documented in Cross-currency swap on Wikipedia.
- Additional market context is at Leadingindicator at Investopedia.
