Read the three candles in time order
Label the bars 1, 2 and 3, with O, H, L and C for open, high, low and close. TA-Lib's detector uses strict comparisons for the third body's engulfment. The table makes that convention explicit; body-size settings and the prior trend still need their own definitions.
- This is a body-gap definition. Overlapping shadows do not automatically reject it; requiring L2 > H1 would impose a different, stricter gap test.
- "Long" and "small" are relative measurements, not fixed dollar amounts. State the lookback and cutoff before comparing detector results.
- The bearish interpretation requires a preceding advance. Geometry found inside a sideways range does not establish an uptrend reversal.
| Bar or relation | Test | Meaning |
|---|
| Candle 1 | C1 > O1; long body | A bullish candle follows the prior rise. |
| Candle 2 | C2 < O2; small body | The first crow is bearish. |
| Initial body gap | C2 > C1 | The entire second body is above the first body. |
| Candle 3 | C3 < O3 | The second crow is also bearish. |
| Engulfment | O3 > O2 and C3 < C2 | The third body extends beyond both ends of the second body. |
| Remaining gap | C3 > C1 | The third close has not entered the first body. |
Work through a hypothetical OHLC example
Assume ordinary candles, a minimum price increment of 0.01 and an established prior rise. These invented prices demonstrate classification only. For this worksheet, use the mean body of the 20 completed bars before candle 1 as a fixed baseline: assume it is 2.00. Require body 1 > 2.00 and body 2 <= 2.00. This common baseline is a custom choice, not a reproduction of TA-Lib defaults.
- The initial body gap is 108.00 - 106.00 = 2.00. Candle 2's low of 106.50 overlaps candle 1's range, but its body remains separate.
- Candle 3 extends 0.50 above candle 2's open and closes 1.00 below its close. Its body contains the entire second body.
- The final body gap is 107.00 - 106.00 = 1.00. The third close preserves the required separation.
- The first body is 3 times the assumed baseline; the second is half the baseline. A different body-size filter can reject this same geometry.
| Candle | Open | High | Low | Close | Body size |
|---|
| 1: bullish | 100.00 | 107.00 | 99.50 | 106.00 | 6.00 |
| 2: first crow | 109.00 | 110.00 | 106.50 | 108.00 | 1.00 |
| 3: second crow | 109.50 | 110.50 | 106.75 | 107.00 | 2.50 |
Reject near misses before evaluating outcomes
Change the indicated price in the worksheet and lower that candle's low when needed to contain the new close. Keep the other values fixed. These cases separate a formation that never qualified from a valid formation whose bearish interpretation later failed. Use tick-aligned prices; do not silently treat a touching body as a gap.
- If a detector accepts equal opens, document that variant. O3 = O2 is outside the strict TA-Lib engulfment condition used here.
- A configurable minimum gap of two ticks would reject the 106.01 boundary example. A minimum gap filters tiny separations; an equality tolerance relaxes a comparison. They are different settings.
- If the third candle later closes differently while still forming, its provisional classification can change. Evaluate the final OHLC values at the bar close.
| Change | Strict result | Reason |
|---|
| C2 = 106.00 | Reject | The second body touches the first body; the initial gap is zero. |
| O3 = 109.00 | Reject | The third open equals the second open; strict engulfment requires a higher open. |
| C3 = 108.00 | Reject | The third close equals the second close; the lower end is not engulfed. |
| C3 = 106.00 | Reject | The final body gap is zero. |
| C3 = 105.50 | Reject | The third close enters the first body. A larger decline does not preserve this pattern's identity. |
| C3 = 106.01 | Accept geometry | One tick of body gap remains, assuming the other filters pass. |
Compare Three Black Crows and Dark Cloud Cover
All three names describe bearish setups, but they select different candle sequences. Count the candles and locate the final close before treating their labels as interchangeable.
- For the worksheet's first candle, the body midpoint is (100.00 + 106.00) / 2 = 103.00. A second candle opening at 109.00 and closing at 102.50 would satisfy the stated Dark Cloud Cover penetration test, but it would fail the upside-gap-two-crows body gap.
- Changing candle 3's close to 105.50 does not automatically create Dark Cloud Cover. Check an actual two-candle pair against its own opening-gap and midpoint rules.
| Pattern | Candle sequence | Decisive distinction |
|---|
| Upside gap two crows | One bullish candle, then two bearish candles | The third body engulfs the second above the first close; a body gap remains. |
| Three Black Crows | Three consecutive long bearish candles | The subsequent candles open within the preceding body and close near their lows; an initial bullish candle and upper body gap are not its defining sequence. |
| Dark Cloud Cover | One large bullish candle, then one bearish candle | TradingView's definition opens candle 2 above candle 1's high and closes it below candle 1's body midpoint. |
Define confirmation and failure as separate events
Here is one optional research protocol, not a trading recommendation: save the pattern after candle 3 closes, then allow the next three completed bars to confirm with a close below candle 1's close. Cancel an unconfirmed candidate if any of those bars trades above the saved pattern high. If both events occur in one bar, cancellation takes priority. Expire the candidate after three bars without confirmation.
- In the worksheet, the confirmation threshold is a close below 106.00 and the cancellation threshold is a high above 110.50. A following bar with H = 109.00 and C = 105.80 confirms; H = 111.00 cancels even if that bar closes at 105.80.
- After confirmation, one illustrative failure measure is a close above 110.50 within the next ten completed bars. Keep that failure in the record instead of deleting the original pattern.
- The three-bar waiting period, ten-bar evaluation period and cancellation priority are declared assumptions. They do not establish a profitable entry or an optimal stop.
- Save the symbol, feed, timeframe and session. If each bar opens exactly at the prior close, a bearish second candle cannot close above that prior close, so this strict body gap cannot occur.
- Use ordinary OHLC candles for these price comparisons. Define entry timing, exits, costs and slippage separately before testing a strategy; chart classification alone produces no return calculation.
Turn the worksheet into a detector brief
Give Pine Script AI Coding Agent the six comparisons, body baseline, minimum gap in ticks and explicit uptrend filter. For example, a prior close above its own 50-bar moving average is a reproducible trend proxy, but it does not prove a sustained advance. Ask for separate markers for a completed shape, confirmation, cancellation and expiry, each recorded when the information becomes available.
- Include the accepted worksheet and rejected boundary cases in the request. Inspect the generated conditions, validate the final Pine source, compile it in TradingView and compare chart labels with the exact OHLC values before creating alerts.
- Upload matched and failed chart screenshots to AI Chart Analysis to review the visible structure and surrounding context. Keep the exchange symbol, timeframe and three candles readable.
- Use the chart's data values to settle one-tick gaps. A screenshot review cannot certify exact inequalities, replace a detector test or establish a future reversal.