Pattern books list dozens of formations. This candlestick pattern scanner TradingView script codes 28 of them and tests every closed bar against all 28 at once. It sizes each candle against a 14-period ATR, so a hammer on gold faces the same relative test as a hammer on EURUSD. The script then tracks follow-through, groups same-direction hits inside a five-bar window, and prints the pattern names straight onto the chart.
It is free and open source. You can add it to any chart from the Candle Genome Scanner script page on TradingView, and the full Pine source is published there for you to read.
What Candle Genome Scanner plots on the price chart
Hits print as tiny labels. Bullish names stack in one teal label under the bar low. Bearish names stack in a red label above the high. Neutral names, Doji and Spin Top, print in an amber label. A cluster recolors that label to a brighter green or red. Bar coloring exists but ships switched off. A nine-row dashboard reports status, the bullish and bearish name lists, cluster state, both reliability rates, total scan counts, and a signal verdict. Six extra values feed the Data Window.

How Candle Genome Scanner is built
Relative candle geometry
Every test uses ratios, not fixed distances. The script measures body as the gap between open and close, then compares it to range and to a 14-period ATR. A small body means body at or under 5 percent of range, which flags Doji and Spinning Top. A big body means body above half the ATR. A long wick means wick over 2.0 times the body, and that ratio drives Hammer, Inverted Hammer, Shooting Star and Hanging Man.
Context comes from a 10-period SMA. A Hammer needs close below that SMA, while a Shooting Star needs close above it. Marubozu demands both wicks under 10 percent of the body. Tweezers need the two lows, or the two highs, within 0.05 ATR of each other. A Morning or Evening Star needs a middle candle with a body under 0.3 ATR.
Double-bar rules compare the current candle with the prior one. Engulfing needs the larger body plus full coverage of the prior open and close. Harami needs the smaller body sitting inside. Piercing needs a close above the prior midpoint but below the prior open. Triple rules add the third bar and check that closes step in order.
Reliability, clusters and filters
The script grades itself. On each detection it pushes direction, bar index and close price into three parallel arrays. Five bars later, set by Follow-Through Bars, it checks the result. A bullish entry scores when close sits above the stored price, a bearish one when close sits below. The dashboard then shows wins over detections as a percentage. The queue holds 200 pending checks.
Clustering works on bar indexes. Every bullish detection pushes the bar index into one array, every bearish one into another, and the script drops entries older than the Cluster Window of five bars. Once two or more remain, the cluster flag turns on and the label switches to the brighter cluster color.
Filter Mode decides what reaches the chart. All shows every hit including neutral ones. Strong Only hides neutral labels and requires the running reliability to clear the Min Reliability percent, which you can set from 0 to 80. Clusters Only keeps just the clustered hits. Six alertcondition entries cover bullish, bearish, either pattern, bullish cluster, bearish cluster and any cluster.
How to read the signals
Read the label first, the dashboard second. A label can carry several names on one bar, stacked line by line, because the script runs all 28 tests together. Three bullish names on one candle means three separate rules passed. That is stronger evidence than a lone Doji, though it is still only one bar of information.
Watch the Cluster row for the sequencing. It reads BULL 3/5 when three bullish bars landed inside the last five. Clusters matter more than single hits, because one candle rarely turns a market on its own. Set Filter Mode to Clusters Only when the chart gets busy, and the tool quiets down fast.
The two reliability rows are a running tally on your loaded history, not a fixed statistic. They show a percentage plus the raw counts, for example 54.0% (27/50). Colors help: green above 60, amber from 40 to 60, red below 40. Scroll back to load more bars and the sample grows.

Every Candle Genome Scanner setting explained
The script exposes 20 inputs, grouped in the settings panel exactly as shown below. Defaults are the published values.
Pattern Detection
| Setting | What it does | Default | Range |
|---|---|---|---|
| ATR Length | ATR period for relative sizing thresholds | 14 | 5 to 50 |
| Small Body % | Max body-to-range ratio for doji/spinning top | 0.05 | 0.01 to 0.2 |
| Wick Ratio | Min wick-to-body ratio for hammer/shooting star | 2.0 | 1.0 to 5.0 |
Pattern Selection
| Setting | What it does | Default | Range |
|---|---|---|---|
| Single-Bar Patterns | Hammer, Shooting Star, Marubozu, Doji variants, Spinning Top | on | on / off |
| Double-Bar Patterns | Engulfing, Harami, Piercing, Dark Cloud, Tweezers, Kicker | on | on / off |
| Triple-Bar Patterns | Morning/Evening Star, 3 Soldiers/Crows, 3 Inside/Outside | on | on / off |
Reliability & Clustering
| Setting | What it does | Default | Range |
|---|---|---|---|
| Follow-Through Bars | Bars after pattern to check directional accuracy | 5 | 3 to 15 |
| Min Reliability % | Only show patterns when reliability is above this (0 = show all) | 0 | 0 to 80 |
| Cluster Window | Bars to look back for pattern clustering | 5 | 2 to 10 |
| Cluster Min Patterns | Minimum same-direction patterns in window for cluster signal | 2 | 2 to 5 |
Display
| Setting | What it does | Default | Range |
|---|---|---|---|
| Filter Mode | All = every pattern | Strong Only = above reliability threshold | Clusters Only = clustered signals only | All | All, Strong Only, Clusters Only |
| Show Dashboard | Toggles show dashboard on the chart. | on | on / off |
| Show Bar Colors | Color bars when patterns detected | off | on / off |
| Table Position | Choose the table position from the listed options. | top_right | top_left, top_center, top_right, middle_left, middle_center, middle_right |
| Text Size | Choose the text size from the listed options. | small | tiny, small, normal |
Colors
| Setting | What it does | Default | Range |
|---|---|---|---|
| Bullish Pattern | Colour used for bullish pattern. | #26A69A | |
| Bearish Pattern | Colour used for bearish pattern. | #EF5350 | |
| Bullish Cluster | Colour used for bullish cluster. | #00C853 | |
| Bearish Cluster | Colour used for bearish cluster. | #D50000 | |
| Neutral Pattern | Colour used for neutral pattern. | #FFD54F |

Alerts built into Candle Genome Scanner
The script ships 6 alert conditions. Open the alert dialog on the chart, pick the indicator as the condition source, then choose the event you want. Alerts fire on the close of the bar, so they follow the same confirmed-bar rule the on-chart signals use.
- Bullish Pattern
- Bearish Pattern
- Bullish Cluster
- Bearish Cluster
- Any Cluster
- Any Pattern
Other markets and timeframes
The rules never use a fixed price distance. Thresholds are either a ratio of the candle’s own range or a multiple of its ATR, so a scan on Bitcoin behaves like a scan on EURUSD. Volume never enters the code, which makes the script safe on spot forex where volume is only a tick proxy. Gapping markets such as single stocks throw more Engulfing and Kicker hits at the open. Round-the-clock markets produce fewer gaps and lean toward wick patterns instead.

Limitations worth knowing
The reliability number is coarse. The script adds every pattern name on a bar to the denominator, yet stores only one pending check per direction per bar. So the percentage reads low when several names print together. It also uses one fixed horizon of five bars and a simple close comparison, with no stop, target or cost model. Treat it as a rough tally.
Pattern rules are approximations of the classic definitions, and the context filter is thin. Only a 10-period SMA supplies trend. The script never checks support, resistance, session time, higher timeframes or volume. Inside a range it will flag plenty of candles that lead nowhere.
TradingView caps the script at 500 labels, so older labels drop off long charts. Reliability counters also start at zero on every reload and depend on how much history your chart holds. Past performance does not predict future results.
Get Candle Genome Scanner on TradingView
Open Candle Genome Scanner on TradingView
If you also trade MetaTrader, the MT4 and MT5 indicator library is available below.
Get the complete indicator library
One email unlocks the full MT4 and MT5 indicator library. This TradingView script stays free on TradingView – the button above adds it to your chart.
Using it alongside MetaTrader
Adding a script on TradingView takes one click, so there is no install step here. If you want the same idea on MetaTrader, the MT4 and MT5 indicator installation guide walks through copying files into the data folder and attaching them to a chart. You can also browse the full MetaTrader indicator library, the MT4 indicators section, or the other free TradingView scripts published on this profile. For related chart tools see the MT5 indicators section and the forex trading strategies guides.
External references
- Candlestick pattern on Wikipedia
- Candlestick at Investopedia
- Candlestick Charts at StockCharts ChartSchool
Frequently asked questions
Does the Candle Genome Scanner repaint?
No. All detection runs inside a barstate.isconfirmed block, so a pattern is only tested and labelled after the bar closes. Nothing appears and then vanishes mid-bar.
Which 28 patterns does it detect?
Ten single-bar forms, including Hammer, Inverted Hammer, Shooting Star, Hanging Man, two Marubozu variants, Doji, Gravestone Doji, Dragonfly Doji and Spinning Top. Ten double-bar forms, covering Engulfing, Harami, Piercing, Dark Cloud, Tweezers and Kicker on both sides. Eight triple-bar forms, covering Morning and Evening Star, Three Soldiers, Three Crows, and Three Inside or Outside on both sides.
What counts as a cluster?
Two or more bars in the same direction firing inside the last five bars, using the default settings. You can raise Cluster Min Patterns to 5 for a stricter grouping, or stretch the Cluster Window to 10 bars for a looser one.
Why does the dashboard say No data under reliability?
The tool has not resolved any pattern yet on that chart. Each detection waits five bars before it scores, and the counters reset when the script reloads. Scroll left to load more history, then let the chart run.
How much should I rely on this indicator?
Treat it as one input, not a decision. It is a chart analysis tool, not trading advice. Test it on your own markets and timeframes before relying on it. Results are not guaranteed; past performance is not indicative of future results.
