Detecting Candlestick Patterns with MQL5
Summary
The article explains how to encode common candlestick formations in MQL5 and mark detected patterns on a chart. It covers single-candle Doji and Hammer patterns, two-candle formations such as Engulfing, Piercing Line, and Dark Cloud Cover, and three-candle Star and Three Inside patterns. The examples use historical OHLC values at specified candle shifts, apply pattern-specific conditions, and create chart arrows and labels when a condition is met.
The Doji example treats an equal open and close as a match, while the other formations are identified by comparing the relative bodies, shadows, and direction of neighboring candles. The article presents pattern detection as a programming aid rather than a complete trading system: it recommends combining candle signals with other technical tools and considering their location in price action. It provides illustrative chart examples but no systematic performance testing, and simple equality checks or fixed pattern rules may not capture every market variation.
Key ideas
- MQL5 price-series functions can retrieve candle time and OHLC values for pattern checks.
- A Doji is identified in the example by an open equal to the close.
- Hammer, two-candle, and three-candle formations can be expressed as conditions on neighboring candle prices.
- Chart objects can display arrows and text at detected candles.
- Candlestick patterns are presented as signals to combine with other analysis, not as standalone guarantees.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.