Harami candlestick: real-body containment vs inside bars
A harami candlestick pattern has a small second real body contained within a larger first real body. A bullish harami follows a decline; a bearish harami follows a rise. An inside bar instead compares the full high-low ranges, including wicks. A pair can meet either rule, both or neither. These shapes identify a setup for review, not a confirmed price reversal.
Key Takeaways
- Use open and close to measure a real body. Use high and low to measure the full candle range.
- Body containment alone is insufficient: specify the preceding trend, relative body sizes and candle colors for your harami definition.
- A Harami Cross replaces the small second body with a doji. Its doji tolerance must be defined.
- Check the completed second candle. A marker on a candle that is still forming can disappear before the close.
Which prices does each pattern compare?
The lower body boundary is the smaller of open and close; the upper boundary is the larger. This works for both candle colors. Schwab defines harami through body containment, while TradingView describes inside bars through containment of the candle range. Neither test implies the other.
| Test | Strict containment | What can still happen? |
|---|---|---|
| Harami body test | Second body bottom is above the first body bottom; second body top is below the first body top. | The second wick can extend beyond the first candle high or low. |
| Inside-bar range test | Second high is below the first high; second low is above the first low. | The second body can extend outside the first body. |
| Inclusive variant | Allow equality at the selected body or range boundaries. | A touching boundary qualifies here but fails the strict test. Label the variant explicitly. |
Bullish harami pattern versus bearish harami
TradingView describes the bullish version as a small green body after a larger red body during a decline. Its bearish version reverses the colors and follows a rise. Some implementations use body containment without requiring opposite colors, so matching the name alone does not establish matching signals.
- Bullish context: a preceding decline, then a large down candle and a smaller up body inside it. A later rise is a separate observation.
- Bearish context: a preceding rise, then a large up candle and a smaller down body inside it. A later decline is a separate observation.
- Record how trend is measured. TradingView offers SMA50, SMA50 with SMA200, or no trend detection; those settings can produce different labels.
- For a custom detector, evaluate prior trend before the two-candle pair. If trend is absent, report body containment without calling it a trend reversal.
Example A: harami body containment without an inside bar
Assume a preceding decline. A1 has a body from 100 to 110. A2 has a smaller bullish body from 103 to 106, strictly inside A1. But A2 reaches 113, above A1 high of 112. The body condition passes and the inside-bar condition fails. Wicks are the reason for the difference.
| Bar | Open | High | Low | Close |
|---|---|---|---|---|
| A1 | 110 | 112 | 98 | 100 |
| A2 | 103 | 113 | 101 | 106 |
Hollow bodies close at or above the open. Filled bodies close below the open.
Hypothetical prices for a boundary comparison, not historical market data. The preceding downtrend is assumed and is not drawn.
Example B: an inside bar without harami body containment
B1 has the same body and range as A1. B2 stays between 99 and 111, inside B1 full range of 98 to 112. Its body starts at 99, below B1 body bottom of 100. It is an inside bar under the strict range rule, but fails the harami body rule even though its bullish body is smaller.
| Bar | Open | High | Low | Close |
|---|---|---|---|---|
| B1 | 110 | 112 | 98 | 100 |
| B2 | 99 | 111 | 99 | 102 |
Hollow bodies close at or above the open. Filled bodies close below the open.
Hypothetical prices. Compare B1 with B2 only; this is a separate example from A1 and A2.
Harami Cross and touching-boundary cases
A Harami Cross uses a doji as the second candle. Its open and close are equal or sufficiently close under a stated tolerance, and its body lies within the first body. The prior trend distinguishes bullish and bearish interpretations. A cross is not evidence of a higher win rate. The examples below compare alternative second candles against a first body from 100 to 110 and range from 98 to 112.
| Second candle: O / H / L / C | Strict body containment | Strict inside bar | Classification detail |
|---|---|---|---|
| 103 / 109 / 102 / 106 | Pass | Pass | Can meet both definitions. |
| 100 / 108 / 99 / 104 | Fail | Pass | Body touches 100. An inclusive body rule would pass. |
| 103 / 112 / 101 / 106 | Pass | Fail | High equals 112. An inclusive range rule would pass. |
| 105 / 107 / 103 / 105 | Pass | Pass | Exact doji: classify as Harami Cross when context qualifies. |
| 109 / 111.5 / 108 / 111 | Fail | Pass | Close exceeds the first body top of 110. |
- One illustrative doji tolerance is body size no more than 5% of the second candle range. This is a chosen test setting, not a universal definition or an asserted TradingView default.
- Handle a zero-range candle separately to avoid dividing by zero. For this example, exclude it from the doji-ratio calculation.
- Classify a qualifying doji as Cross before assigning an ordinary harami label if you want mutually exclusive counts.
Separate pattern completion from reversal confirmation
The two-candle shape can be checked at the second close. Confirmation of a later move requires another rule and therefore arrives later. For an illustrative bullish test, require a subsequent close above the higher high of the pair within three bars. Cancel the untriggered setup if price first breaks the lower low, or if three bars pass without confirmation. Reverse the directions for a bearish test.
- This confirmation rule is an example, not part of the harami definition. A small rise inside the pair does not satisfy it.
- If a bar breaches the invalidation level and also closes beyond the confirmation level, this example cancels the setup. Do not assume a favorable intrabar sequence from OHLC alone.
- A failed reversal does not erase the original completed pattern. It shows why pattern detection and trade outcomes must be counted separately.
- TradingView documents changing high, low and close values on open bars. Match alerts to completed candles if that is how historical signals are evaluated.
- Any trading test also needs entry timing, exits, fees and slippage. No universal win rate or best timeframe is established by these examples.
Specify two detectors before asking for a script
Keep body containment and full-range containment as separate outputs. A Pineify AI Coding Agent request can describe both and ask for distinct labels, with a third label when both pass. Review the resulting script against the illustrated cases before using its alerts.
- Specify strict or inclusive comparisons, opposite-color requirements, the trend lookback and when each condition is measured.
- Define large and small bodies numerically. An illustrative starting specification requires the first body to exceed the mean body size of the 20 bars before the pair, and the second body to be at most half the first. These values require testing.
- State a doji tolerance, exclude zero ranges and decide whether Cross labels replace ordinary harami labels.
- Request labels only after the second candle closes. Test the equal-boundary and wick-extension cases separately from trading performance.
Pineify next step
Draft separate harami and inside-bar rules
Give Pineify AI Coding Agent your body, wick, trend and doji rules to draft a Pine Script indicator. Check its labels against the examples and review its alert timing in TradingView. Generated code still needs behavioral testing.
This page is educational and does not provide investment advice. All illustrated prices, thresholds and confirmation rules are hypothetical examples, not measured performance or trading recommendations. Pattern labels do not guarantee reversals. Trading can cause substantial losses.