The candlestick pattern detector indicator watches for six named formations and colours each one differently. Engulfing bars, hammers, shooting stars, morning stars and evening stars all get their own arrow. Rather than fixed pip rules, the tests work on proportions, so a pattern qualifies the same way on a calm pair and a fast one.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 6: BullEngulf, BearEngulf, Hammer, ShootingStar, MorningStar, EveningStar |
| Alerts | popup |
| Inputs | 7 |
What the Candlestick Pattern Detector Indicator draws on the chart
BullEngulf and BearEngulf mark engulfing bars in lime and red.
Hammer uses dodger blue below the candle; ShootingStar uses orange above it.
MorningStar in aqua and EveningStar in magenta are drawn thicker and pushed further from price, since they are three-bar formations.
Text objects name each pattern beside its arrow when labels stay switched on.
- BullEngulf: arrow, lime, width 2, arrow code 233
- BearEngulf: arrow, red, width 2, arrow code 234
- Hammer: arrow, dodger blue, width 2, arrow code 233
- ShootingStar: arrow, orange, width 2, arrow code 234
- MorningStar: arrow, aqua, width 3, arrow code 233
- EveningStar: arrow, magenta, width 3, arrow code 234

How the Candlestick Pattern Detector Indicator calculates its values
Measuring bodies against ranges
Two helpers do the groundwork. Range returns the high to low span of a bar and Body returns the open to close distance. From these the code derives rng1, rng2, bod1 and bod2 for the neighbouring bars. Every pattern test then works on a ratio of body to range rather than an absolute size, which is what makes the settings portable between instruments.
Engulfing, hammer and shooting star
An engulfing bull needs close[i] above open[i + 1] while open[i] sits below close[i + 1], so the current body swallows the previous one. Hammer and shooting star lean on `DetWickRatio` instead, demanding the wick reach a multiple of the body. The code writes HammerBuf at low[i] minus the offset and ShootBuf at high[i] plus it.
The three-bar star patterns
A morning star needs a sequence. b2_bear requires bar i+2 to be bearish with a body share of at least `DetBodyRatio`. b1_small requires the middle bar to stay under `DetSmallBodyRatio`. b0_bull requires the current bar to close bullish and solid. On top of that, gapDown checks the middle bar opened and closed below close[i + 2], and closeAbove checks the current close cleared mid2, the midpoint of the first candle. The evening star inverts every one of these.
How to read the signals
Arrow colour identifies the pattern, so a chart with several colours is showing several different formations.
The star arrows sit further from price because they describe three bars, not one.
A pattern with no trend behind it carries less weight. This build tests shape only.
Turning labels off leaves the arrows, which keeps a busy chart readable.
Alert channels in this build: popup, one message per closed bar.
A terminal popup is the only channel, controlled by `DetEnableAlerts` at its `true` default. Detection runs on completed bars and the guard permits one message per closed bar, so a candle that looks like a hammer while forming raises nothing until it finishes that way.
Every Candlestick Pattern Detector Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
DetBodyRatio |
min body/range for solid candle. Minimum body share of range for a candle to count as solid, default `0.55`. Raise it to demand more decisive bars. | 0.55 |
DetWickRatio |
wick must be N x body for hammer/star. How many times the body a wick must reach for a hammer or shooting star, default `2.0`. | 2.0 |
DetSmallBodyRatio |
max body/range for star middle bar. Largest body share allowed for the middle bar of a star, default `0.35`. Lower it to insist on a true doji in the middle. | 0.35 |
Display settings
| Setting | What it does | Default |
|---|---|---|
DetArrowOffset |
arrow offset in points. Gap between candle and arrow in points, default `10`. | 10 |
DetShowLabels |
show OBJ_TEXT pattern labels. Set it `false` to drop the text objects and keep the arrows only. | on |
DetLabelPrefix |
chart object prefix. Names those text objects, default `”CPDet_”`. | CPDet_ |
Alert settings
| Setting | What it does | Default |
|---|---|---|
DetEnableAlerts |
enable alerts. | on |

Settings that fit your chart
Pattern recognition needs candles with real bodies, so H1 and above give the cleanest reads. EURUSD H1 is the reference chart. On M1 the spread often exceeds the body and the ratio tests produce constant noise. Instruments that gap, such as indices at the cash open, throw extra star patterns that a 24-hour forex pair never shows.
When the Candlestick Pattern Detector Indicator fails
The tool checks shape without checking context. An engulfing bar mid-range means far less than the same bar at a tested level, and both get identical arrows.
Ratio thresholds create edge cases. A body at 0.549 of range fails while 0.551 passes, and those two candles look identical on screen.
Forex rarely gaps, so the gapDown and gapUp conditions inside the star tests fire less often than a stock trader would expect.
Copy the compiled Candlestick Pattern Detector Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Candlestick Pattern Detector Indicator for MT4 and MT5
The zip holds the compiled Candlestick Pattern Detector Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
What does DetBodyRatio at 0.55 require?
That the candle’s body covers at least 55% of its high to low range. That threshold separates a decisive candle from one that spent most of its life wicking around. It gates the engulfing tests and both ends of the star patterns. Raise it toward 0.7 for stricter detection and noticeably fewer arrows.
Why do MorningStar arrows sit further from the candle?
The code multiplies the offset by 1.5 for both star buffers. Star patterns describe three bars, so their arrow needs to stand apart from any single-bar arrow that lands nearby. It also stops a morning star and a hammer overlapping when both trigger on the same candle.
Which six patterns does the candlestick pattern detector indicator find?
Bullish and bearish engulfing, hammer, shooting star, morning star and evening star. Each has its own buffer and its own colour, so you can tell them apart without reading the labels. There is no on and off switch per pattern; all six run whenever the indicator is attached.
What is DetSmallBodyRatio filtering?
The middle bar of a three-bar star. That candle should show hesitation, so its body must stay at or below 35% of its range by default. Lower the value to insist on something closer to a true doji in the middle, which cuts the star count and leaves the cleaner examples.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Candlestick Pattern Detector Indicator as one input. Always backtest before trading live.
Category: this is part of our Candle Sticks collection. Also, truly, browse more Candle Sticks for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- Learn more about the underlying method in Introduction To Candlesticks at StockCharts ChartSchool.
- For wider market background, see Morning star (candlestick pattern) on Wikipedia.
