Skip to content
All library documents

Automating Head and Shoulders Pattern Trades with an MQL5 Expert Advisor

Article MQL5 articles

Summary

This tutorial outlines an MQL5 Expert Advisor that detects standard and inverse Head and Shoulders formations, marks their swing points on a chart, and places trades after a neckline breakout is confirmed by a candle close. For an inverse setup, the described buy uses the low at the second shoulder as its stop and the initial swing high as its first target; the sell logic mirrors these placements. If the pattern-based target is less than the stop distance from entry, the method substitutes a fixed risk-to-reward target. The article also covers chart objects for visual inspection and tracking the signal bar to avoid repeated entries from the same pattern.

The material is primarily a programming walkthrough: it connects swing-point identification, pattern visualization, trade-level selection, and order execution. It explains reversal-pattern concepts but supplies no backtest results or evidence that the detection rules are profitable. Pattern definitions such as roughly equal shoulders and neckline swings need operational thresholds in an implementation, and the article frames the project as educational rather than a ready-to-use live strategy. Any performance assessment would require independent testing across instruments and market conditions.

Key ideas

  • The EA identifies six ordered swing points to describe standard and inverse Head and Shoulders formations.
  • A candle close beyond the neckline triggers the corresponding trade direction.
  • The stop is placed at the second shoulder, while the initial target is the first swing point.
  • When the pattern target offers less distance than the stop, the method uses a fixed risk-to-reward target.
  • Chart annotations support visual checking, while signal-bar tracking helps prevent duplicate entries.
  • The tutorial describes implementation logic but provides no evidence of trading performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.