Discussing the article: "Automating Chart Patterns in MQL5 (Part 3): The Head and Shoulders and Inverse Head and Shoulders"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Automating Chart Patterns in MQL5 (Part 3): The Head and Shoulders and Inverse Head and Shoulders.
The Head and Shoulders is widely regarded as one of the most reliable reversal patterns in technical analysis. It describes a market that has made three successive peaks during a distribution phase: a left shoulder, a higher head, and a right shoulder that fails to reach the head. The pattern completes when price breaks below the neckline connecting the two intervening troughs. At that moment, the prior uptrend has been structurally broken at three distinct levels, and the evidence for a reversal is stronger than either a Double Top or a single swing high.
In Part 1 of this series, we built CSwingEngine, a swing detection engine that reads market structure from a higher timeframe and labels confirmed swings as HH, LH, HL, or LL. Part 2 applied that engine to double-top and double-bottom patterns. This article applies the same architecture to a pattern with more moving parts: the Head and Shoulders.
The pattern is well known but poorly automated. Most implementations search for three peaks of approximately the right height without asking whether those peaks formed in the correct structural sequence. A head that is geometrically higher than both shoulders is necessary but not sufficient. The left shoulder must form during an uptrend. The head must represent the final push to a new high. The right shoulder must be a lower high, the market's first failure to continue the trend. The neckline break must occur after the right shoulder has fully formed and been confirmed.
This article enforces all of those requirements in code. The swing engine classifies H4 market structure and assigns HH, LH, HL, and LL labels to each confirmed swing point. The detector reads those labels directly to verify the structural sequence, not as a geometric approximation, but as a structural classification. The neckline break that triggers entry is timed on the EA's own chart timeframe for precision.
Author: Tola Moses Hector