Discussing the article: "Automating Trading Strategies in MQL5 (Part 8): Building an Expert Advisor with Butterfly Harmonic Patterns"

 

Check out the new article: Automating Trading Strategies in MQL5 (Part 8): Building an Expert Advisor with Butterfly Harmonic Patterns.

In this article, we build an MQL5 Expert Advisor to detect Butterfly harmonic patterns. We identify pivot points and validate Fibonacci levels to confirm the pattern. We then visualize the pattern on the chart and automatically execute trades when confirmed.

The Butterfly pattern is a precise geometric formation defined by five key swing or pivot points—X, A, B, C, and D—and comes in two primary types: a bearish pattern and a bullish pattern. In a bearish Butterfly, the structure forms a high-low-high-low-high sequence where pivot X is a swing high, pivot A a swing low, pivot B a swing high, pivot C a swing low, and pivot D a swing high (with D positioned above X). Conversely, a bullish Butterfly is formed in a low-high-low-high-low sequence, with pivot X as a swing low and pivot D falling below X. Below are the visualized pattern types.

Bearish Butterfly Harmonic Pattern:

BEARISH

Bullish Butterfly Harmonic Pattern:

BULLISH

Author: Allan Munene Mutiiria

 
Could you provide the entire code, please?