Automating Gartley Pattern Detection and Trading in MQL5
Summary
This tutorial describes an MQL5 Expert Advisor that identifies bullish and bearish Gartley harmonic patterns from price swings. It uses neighboring bars to mark swing highs and lows, then checks the XABCD structure against configurable Fibonacci retracement and extension ranges. Chart objects display the detected legs, and the EA can generate trades after confirming point D, with a stop at the D swing and a take profit based on a 1:3 risk-to-reward target.
The article presents implementation steps and code examples for loading candle data, identifying swing points, and drawing pattern markers. It frames the method as a starting point that could be adapted to other harmonic formations. It does not provide backtest results or evidence that the signals are profitable. Detection depends on chosen swing lookbacks and Fibonacci tolerances, while a confirmed chart pattern does not establish that price will reverse. The suggested trade levels are design choices rather than validated risk controls.
Key ideas
- The EA identifies candidate XABCD structures by detecting swing highs and lows in candle data.
- Fibonacci relationships between the pattern legs are configurable inputs to the detector.
- Bullish and bearish Gartley setups use mirrored swing sequences and trade directions.
- The example places a stop at point D and sets take profit at three times the stop distance.
- The article gives implementation guidance but no backtest evidence for profitability.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.