On this page
What Candlestick Pattern detects
Candlestick Pattern recognizes 27 named formations from Open, High, Low and Close. It draws an arrow and English label for the selected pattern on a closed candle. It does not measure volume, spread or the probability of a reversal. Names describe this implementation’s rules, not a complete trade entry, stop or exit.
ForexBestRobots edition 1.04 is a marked derivative of EarnForex 1.03. It adds valid-window checks, consistent buffer clearing, isolated object ownership and silent initial/resumed scans. It corrects the Marubozu Down wick comparisons. Dependencies are embedded in one source file; unchanged original modules, copyright and Apache 2.0 remain in each package.
Rules, pattern IDs and priority
Let R=High−Low and B=abs(Close−Open). Neutral Doji requires B<0.05×R and excludes Dragonfly/Gravestone shapes. Equality at 5% does not qualify; a completely flat zero-range candle is not a Doji here. Marubozu needs B>0.95×R and each relevant wick below 2% of range. The corrected Down rule mirrors Up.
Several definitions differ from common textbook shortcuts. Engulfing requires the current body to exceed the previous full range and its Close to pass the previous High/Low. Tweezer tolerance is ±5% of quoted price, not five points. Harami uses 5 candles including three earlier body midpoints; Three-Line Strike uses 4, but its final candle only has to engulf the immediately preceding body. Most rules have no separate trend filter.
Only one enabled matching rule wins per candle, in source-code priority, not numeric ID order. Group filters are applied after selection; filtering out the winner does not fall through to a lower-priority match. Hanging Man and Inverted Hammer, both Spinning Tops and all Doji variants have direction 0 here. A downward arrow on an uncertain label is placement, not a sell instruction.
Buffer 0 contains 1 for bullish, -1 for bearish or 0 for uncertain/no result. Buffer 1 contains the selected ID 1–27; 0 means no result. Read both together: a Doji is 0/1, while no pattern is 0/0. Open shift 0, invalid windows and positions outside the scan limit are zero. The table lists each rule’s minimum source history.
R = High - Low
B = abs(Close - Open)
DojiBody = (B < 0.05 * R)
Buffer0 ∈ {-1, 0, 1}
Buffer1 ∈ {0, 1, ..., 27}
shift0 = 0; source_shift >= 1| ID | Pattern | Direction | Required candles |
|---|---|---|---|
| 1 | Doji | Uncertain · 0 | 1 |
| 2 | Dragonfly Doji | Uncertain · 0 | 1 |
| 3 | Gravestone Doji | Uncertain · 0 | 1 |
| 4 | Bullish Spinning Top | Uncertain · 0 | 1 |
| 5 | Bearish Spinning Top | Uncertain · 0 | 1 |
| 6 | Marubozu Up | Bullish · 1 | 1 |
| 7 | Marubozu Down | Bearish · -1 | 1 |
| 8 | Hammer | Bullish · 1 | 1 |
| 9 | Hanging Man | Uncertain · 0 | 1 |
| 10 | Inverted Hammer | Uncertain · 0 | 1 |
| 11 | Shooting Star | Bearish · -1 | 1 |
| 12 | Bullish Engulfing | Bullish · 1 | 2 |
| 13 | Bearish Engulfing | Bearish · -1 | 2 |
| 14 | Tweezer Top | Bearish · -1 | 2 |
| 15 | Tweezer Bottom | Bullish · 1 | 2 |
| 16 | Three White Soldiers | Bullish · 1 | 3 |
| 17 | Three Black Crows | Bearish · -1 | 3 |
| 18 | Three Inside Up | Bullish · 1 | 3 |
| 19 | Three Inside Down | Bearish · -1 | 3 |
| 20 | Morning Star | Bullish · 1 | 3 |
| 21 | Evening Star | Bearish · -1 | 3 |
| 22 | Bullish Harami | Bullish · 1 | 5 |
| 23 | Bearish Harami | Bearish · -1 | 5 |
| 24 | Bullish Three-Line Strike | Bullish · 1 | 4 |
| 25 | Bearish Three-Line Strike | Bearish · -1 | 4 |
| 26 | Three Outside Up | Bullish · 1 | 3 |
| 27 | Three Outside Down | Bearish · -1 | 3 |
Real EUR/USD examples
The figures reconstruct archived Yahoo Finance EUR/USD H1 OHLC, normalized to five decimals before detection. CSVs retain the raw values and four earlier context candles. Letters highlight selected examples only; labels and colors are illustrative. These are not MetaTrader screenshots, live alert logs or performance backtests. Times are UTC; the program uses broker time.
On 3 June 2025, A at 01:00 is Marubozu Down (7), B at 09:00 Doji (1), C at 20:00 Gravestone Doji (3) and D at 22:00 Hammer (8). Their next available openings are 02:00, 10:00, 21:00 and 23:00. On 4 June, Three Outside Up (26) at 07:00 is observable at 08:00; Bullish Engulfing (12) at 12:00 is observable at 13:00, while rule 6 also matches.
The priority comparison uses the same 4 June 06:00 candle, observable at 07:00. Default selection is Bearish Three-Line Strike (25), direction -1, although the final candle is bullish. Setting DetectBearishThreeLineStrike=false exposes Bullish Engulfing (12), direction 1. Setting only DetectBearish=false instead yields no result: category filtering does not choose the next rule. This is a software-selection example, not a performance comparison.



Chart timeframe and confirmation
The indicator uses the current chart symbol and timeframe; there is no MTF projection. H1 examples describe hourly source candles only. Changing broker, timeframe or precision can change the formations. Some rules require up to 5 completed source candles, including context before the visible or scanned section.
A notification is evaluated when a new opening timestamp is available, using the last closed candle, shift 1. After missing quotes or a weekend, this may be later than its nominal close. Corrections to history can change an earlier label. Closed-candle processing does not guarantee identical results across feeds or immutable history.
Settings and defaults
There are 44 functional inputs and 6 Comment_* separators. MaxCandle defaults to 500 completed source positions; 0 scans all loaded closed candles. Valid values are 0–1000000. Older context can still be read for the earliest scanned positions. All 27 individual switches and all three group switches are initially true.
IndicatorName is also the per-chart object prefix: use 1–20 unique ASCII letters, digits, underscores or hyphens. A duplicate FBR chart/prefix is rejected without deleting the first copy. FontSize accepts 6–48, Font 1–80 characters, Xoff/Yoff 0–5000 and ChartCorner one of the four corners. Original colors are green/red/black; change the uncertain-label color for a dark chart. Large scans can create many objects.
| Input | Default | Practical meaning |
|---|---|---|
Comment_1 | "====================" | Main-section separator only. |
IndicatorName | "PTRNDET" | Unique chart prefix; 1–20 ASCII letters/digits/_/-. |
Comment_2 | "====================" | Detection-section separator only. |
MaxCandle | 500 | Completed positions to scan; 500 initially, 0 all; maximum 1000000. |
DetectBullish | true | Allow the selected bullish category; no priority fallback. |
DetectBearish | true | Allow the selected bearish category; no priority fallback. |
DetectUncertain | true | Allow the selected uncertain category. |
Comment_2a | "====================" | Individual-pattern separator only. |
DetectDojiNeutral | true | Enable the Doji rule. |
DetectDojiDragonfly | true | Enable the Dragonfly Doji rule. |
DetectDojiGravestone | true | Enable the Gravestone Doji rule. |
DetectSpinningTopBull | true | Enable the Bullish Spinning Top rule. |
DetectSpinningTopBear | true | Enable the Bearish Spinning Top rule. |
DetectMarubozuUp | true | Enable the Marubozu Up rule. |
DetectMarubozuDown | true | Enable the Marubozu Down rule. |
DetectHammer | true | Enable the Hammer rule. |
DetectHangingMan | true | Enable the Hanging Man rule. |
DetectInvertedHammer | true | Enable the Inverted Hammer rule. |
DetectShootingStar | true | Enable the Shooting Star rule. |
DetectEngulfingBull | true | Enable the Bullish Engulfing rule. |
DetectEngulfingBear | true | Enable the Bearish Engulfing rule. |
DetectTweezerTop | true | Enable the Tweezer Top rule. |
DetectTweezerBottom | true | Enable the Tweezer Bottom rule. |
DetectThreeWhiteSoldier | true | Enable the Three White Soldiers rule. |
DetectThreeBlackCrows | true | Enable the Three Black Crows rule. |
DetectThreeInsideUp | true | Enable the Three Inside Up rule. |
DetectThreeInsideDown | true | Enable the Three Inside Down rule. |
DetectMorningStar | true | Enable the Morning Star rule. |
DetectEveningStar | true | Enable the Evening Star rule. |
DetectBullishHarami | true | Enable the Bullish Harami rule. |
DetectBearishHarami | true | Enable the Bearish Harami rule. |
DetectBullishThreeLineStrike | true | Enable the Bullish Three-Line Strike rule. |
DetectBearishThreeLineStrike | true | Enable the Bearish Three-Line Strike rule. |
DetectThreeOutsideUp | true | Enable the Three Outside Up rule. |
DetectThreeOutsideDown | true | Enable the Three Outside Down rule. |
Comment_2b | "====================" | Display-section separator only. |
Font | "Verdana" | Label font; 1–80 characters. |
FontSize | 8 | Label font size; 6–48, initially 8. |
FontColorBullish | clrGreen | Bullish text/arrow color. |
FontColorBearish | clrRed | Bearish text/arrow color. |
FontColorUncertain | clrBlack | Uncertain text/arrow color; initially black. |
Comment_3 | "====================" | Notification-section separator only. |
EnableNotify | false | Master notification switch; off by default. |
SendAlert | true | Popup; active only with EnableNotify. |
SendApp | false | Push; configure the terminal first. |
SendEmail | false | Email; configure the terminal first. |
Comment_4 | "====================" | Panel-section separator only. |
ChartCorner | CORNER_LEFT_UPPER | One of the four chart corners. |
Xoff | 20 | Horizontal panel spacing; 0–5000, initially 20. |
Yoff | 20 | Vertical panel spacing; 0–5000, initially 20. |
Pause, clear and notifications
EnableNotify=false is the master default despite SendAlert=true. Popup, push and email are available; there is no separate WAV-file channel. Sound depends on the terminal’s alert settings. Push/email need a configured, online desktop terminal. Messages contain symbol, timeframe, pattern and source/observation times, without account-name or login fields. No orders are executed.
Initial attachment, explicit history reset and resuming detection rebuild silently. Thereafter only the newest closed pattern is processed once per new opening timestamp, even when the history length stays capped. There is no queue of old patterns or every-tick retry after a failed notification attempt.
Pause stops scanning and new notifications, keeps existing markers and clears both buffers. Clear removes this instance’s markers, clears buffers and leaves detection paused. Resume rebuilds on the next calculation without sending old alerts. Chart-scale changes reposition visible labels; a new scan replaces the instance’s prior markers.
Install and compile the source
- Extract the ZIP for MT4 or MT5.
- In desktop MetaTrader choose File → Open Data Folder, then MQL4 or MQL5.
- Copy the ZIP’s Indicators folder there; keep upstream separately as the unchanged reference.
- Open Candlestick_Pattern_ForexBestRobots.mq4 or .mq5 in the matching MetaEditor, press F7 and inspect diagnostics.
- Refresh Navigator → Indicators and attach the compiled program to a demo chart with a unique IndicatorName.
- Start with EnableNotify off. Check IDs, direction, scan limit, priority and panel behavior before configuring and demo-testing notification channels.
The download contains MQ4/MQ5 source, without ready EX4/EX5 binaries. Custom desktop indicators cannot be installed directly into MetaTrader mobile. Copy only our marked Indicators folder for normal installation; upstream contains original reference files, not required dependencies. CSVs explain the figures and are not indicators.
Download Candlestick Pattern free
Download the platform ZIP directly from this site. It includes marked self-contained source, unchanged original main/include modules, Apache 2.0, change notes, a textual patch, checksums and installation notes in all 12 site languages. No registration, DLL or external include is required by our marked source.
Compile with F7 in the matching desktop MetaEditor, inspect errors and warnings, then demo-test. Numerical and modeled-API checks outside MetaTrader do not verify native compilation, terminal rendering, chart events, broker history or actual notification delivery.
Free source ZIP · ForexBestRobots edition 1.04 · Compile in MetaEditor
Detection limits and changing history
A pattern ID is a classification, not a win rate or prediction. Several formulas are simplified, and a named bullish/bearish category does not necessarily match the final candle’s color. Prices, session boundaries and rounding near strict thresholds can change the winner.
The chart contains selected objects, while buffers describe the currently processed history. Paused buffers are zero even if old labels remain visible. A group filter and an individual pattern switch can produce different outcomes because priority is evaluated first.
No spread, commission, slippage, position size or exit model is included. The examples establish no trading performance. This edition retains the documented upstream definitions except the marked Marubozu Down wick correction; compare code conventions before comparing other detectors.
Frequently asked questions
Does it recognize all candlestick patterns?
No. It implements 27 named rules with specific definitions. Other detectors may use different thresholds or context.
Why is only one pattern shown?
The first enabled match in code priority wins. Numeric ID order is different. Group filtering after selection does not fall through.
Does direction 0 mean no pattern?
Not necessarily. Check buffer 1 too: 0/1 is Doji, while 0/0 means no result.
Are notifications confirmed on a closed candle?
Yes. The latest closed shift 1 is processed at the next available opening. Initial and resumed scans are silent.
What do Pause and Clear do?
Pause keeps markers but clears buffers and stops scanning/notifications. Clear also removes the markers and leaves detection paused.
Can I run multiple copies?
Yes, with different IndicatorName prefixes on the same chart. Duplicate FBR chart/prefix ownership is rejected.
Are these compiled files tested inside MetaTrader?
No. They are MQ4/MQ5 sources for desktop MetaEditor. External checks do not verify native compilation or runtime.
Sources and verification scope
The review follows the pinned EarnForex source and our marked changes. Original copyright is preserved. Reconstructions are our calculations on archived real quotes. Inclusion and modification do not imply endorsement by EarnForex.