Candle Pattern Recognition Unit - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources


Candlestick patterns originated from Japanese rice traders in the 18th century and were designed to capture market psychology through price action (open, high, low, close). Patterns such as the three black crows, bullish engulfing or doji reflect changes in supply and demand, signaling reversals or continuations based on trader sentiment. These models work best in less efficient markets with less liquidity and fewer automated systems, as they rely on human behavior and manual trading decisions.
This project is a method of detecting the formation of all well-known candlestick patterns and graphically marking all bullish patterns with green lines and all bearish patterns with red lines. MetaQuotes released some code specifically for expert advisors more than 10 years ago. This is a candle pattern library, and part of the logic is borrowed from this library. This library cannot be used in indicators, so the code was written completely from scratch. This gave me the opportunity to test and redefine many of the pattern detection features to achieve high quality pattern detection. Large institutions (e.g., hedge funds, market makers) use sophisticated strategies, including machine learning and quantitative models, to analyze large data sets that go beyond simple price patterns. They may predict how retail traders will react to candlestick patterns and take positions against them, especially in liquid markets such as Forex or major indices.
Is the model outdated?
Not exactly. Candlestick patterns remain valuable because they reflect the human and algorithmic psychology embedded in price action. Both retail and institutional traders monitor key patterns (such as hammers at support levels), and when many traders act on the same signal, a self-fulfilling prophecy can occur.
Context matters: Isolated patterns are less effective. Their reliability increases when combined with other factors such as support/resistance levels, volume or trend indicators.
A 2019 analysis of FX candlestick patterns found that patterns such as Doji and Engulfing were statistically significant in predicting short-term reversals, but their advantage diminished in high-frequency environments due to market noise and institutional counter-strategies.
In trending markets, continuation patterns (e.g., three white soldiers) can be reliable, but in volatile markets, reversal patterns tend to fail.
Institutions are not always smarter than patterns. Big players also use candlestick patterns as part of a wider strategy, especially at key levels (e.g. Fibonacci retracements, pivot points).
In indicators, the average is used to determine the average body size of a period of candles. Entering the option "Use State Machine" will change the indicator so that if a bullish pattern is found, it will ignore the next bullish pattern until the next bearish pattern is found, and when the next bearish pattern is found, it will ignore the next bearish pattern until the next bullish pattern is found.
The indicator also has two different modes: "Form Immediately", which means that the pattern it detects is without lag (but with the risk of redrawing), and "Formation Confirmed", which means that the pattern was confirmed in the previous bar and there will not be any redrawing.
Attachment download
📎 Candle_Pattern_Signal.mq5 (35.54 KB)
Source: MQL5 #62938
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •