Choose a gap definition before comparing detectors
The sources use different tests. Thomas Bulkowski describes gaps between the shadows of the first two candles. TA-Lib's CDLXSIDEGAP3METHODS implementation compares real bodies and requires the third open inside the second body and third close inside the first. Its condition does not test a prior trend or a minimum body length. A match in one implementation can therefore be absent in another.
- Number the completed candles 1, 2 and 3, oldest first. O, H, L and C mean ordinary open, high, low and close.
- The worked specification below combines full-range separation with strict body containment. Its extra trend, body-size and tick thresholds are research choices, not a reproduction of TA-Lib or a TradingView built-in default.
| Gap measure | Downside | Upside |
|---|
| Real bodies, assuming the stated colors | C1 - O2 > 0 | O2 - C1 > 0 |
| Full high-low ranges | L1 - H2 > 0 | L2 - H1 > 0 |
| Gap interval for the full-range version | H2 to L1 | H1 to L2 |
A complete rule sheet with explicit tolerances
Use a positive minimum tick t. Require the five closes immediately before candle 1 to fall strictly for the downside version or rise strictly for the upside version. Define a long body as at least 1.5 times the mean absolute body over the 20 bars before candle 1. Require both first bodies to meet that threshold and reject a zero baseline. These filters make the example reproducible; they are not optimized settings.
- A wick touch gives a zero gap and fails. A third close exactly on a first-body endpoint also fails the one-tick-inside rule, even when it has crossed the entire high-low gap.
- Use prices on the instrument's tick grid. Do not round a failing observation into a match. Reject missing data, insufficient reference history and invalid OHLC where H < max(O, C), L > min(O, C), or H < L.
- Keep full-range and body-gap results in separate samples. Relaxing the wick test changes the detector, rather than fixing an error in the stricter version.
| Condition | Downside gap three methods | Upside gap three methods |
|---|
| First two directions | C1 < O1 and C2 < O2 | C1 > O1 and C2 > O2 |
| Full-range gap of at least one tick | L1 - H2 >= t | L2 - H1 >= t |
| Third direction | C3 > O3 | C3 < O3 |
| Third open, at least one tick inside body 2 | C2 + t <= O3 <= O2 - t | O2 + t <= O3 <= C2 - t |
| Third close, at least one tick inside body 1 | C1 + t <= C3 <= O1 - t | O1 + t <= C3 <= C1 - t |
| When to record the shape | After candle 3 closes | After candle 3 closes |
Recalculate a downside example and its upside mirror
These hypothetical prices use t = 0.01 and a prior 20-bar mean body of 3, so the long-body threshold is 4.5. The first two bodies are both 5. Assume five preceding closes of 116, 115, 114, 113 and 112 for downside, and 84, 85, 86, 87 and 88 for upside. Each tuple is (open, high, low, close).
- For downside, close-based fill = 100 × clamp((C3 - H2) / G, 0, 1). For upside, it is 100 × clamp((L2 - C3) / G, 0, 1). Clamp limits the ratio to the interval 0 to 1. Calculate it only when G > 0.
- Both examples fill 100%: the raw ratio is 4 / 2 = 2, capped at 1. The third close travels two price units beyond the far edge of the full-range gap and ends inside body 1.
- In the downside example, change only C3 to 103. The close has filled (103 - 102) / 2 = 50%, while H3 = 107 shows an intrabar fill. It fails the required close inside body 1. A wick fill and a closing fill must be recorded separately.
- Change downside C3 to 104: the full-range gap is 100% filled, but C3 remains below body 1, which starts at 105. The complete pattern still fails. At C3 = 105.00 it touches the body endpoint and fails; at 105.01 it passes that boundary.
- Change downside H2 to 104: the bodies remain separated by 4, but the full-range gap is zero. The strict version fails, and its fill ratio is undefined. Change H2 to 105 to create overlapping wicks; the body-gap condition remains true.
| Observation | Downside example | Upside example |
|---|
| Candle 1 | (110, 111, 104, 105) | (90, 96, 89, 95) |
| Candle 2 | (101, 102, 95, 96) | (99, 105, 98, 104) |
| Candle 3 | (99, 107, 98, 106) | (101, 102, 93, 94) |
| Full-range gap G | 104 - 102 = 2 | 98 - 96 = 2 |
| Body gap | 105 - 101 = 4 | 99 - 95 = 4 |
| Third open inside body 2 | 96.01 <= 99 <= 100.99 | 99.01 <= 101 <= 103.99 |
| Third close inside body 1 | 105.01 <= 106 <= 109.99 | 90.01 <= 94 <= 94.99 |
Compare Tasuki, five-candle methods and gapping plays
Use the position of the third close to separate a Tasuki gap from gap three methods. TradingView describes Tasuki as a three-candle continuation pattern whose opposing third candle closes within the gap without filling it completely. A partial fill alone is not enough to establish every Tasuki condition; compare the trend, body directions and opening relationships too.
- Steve Nison's Candlecharts describes high-price and low-price gapping plays around a consolidation. Those are related gap structures, not alternate names for this three-candle fill pattern.
- The word three in rising or falling three methods refers to the middle consolidation group in the standard five-candle description. Do not substitute that detector for gap three methods.
| Pattern family | Structure | Distinguishing observation |
|---|
| Upside or downside gap three methods | Three candles; first two share a direction and gap apart | The opposing third body crosses the gap and closes inside body 1 in the specification here |
| Upside or downside Tasuki gap | Three candles with an opposing third candle | The third close remains within the gap; it does not fully close it |
| Rising or falling three methods | Five candles in the TradingView definition | Three small opposing bodies sit within candle 1 range; candle 5 resumes the original direction and closes beyond candle 1 close |
| High price gapping play | Advance, small-body consolidation near the highs, then a gap above it | The gap follows the consolidation; a third-candle fill is not its defining test |
| Low price gapping play | Decline, small-body consolidation near the lows, then a gap below it | The downside counterpart of the high-price consolidation breakout |
Separate completion, confirmation and later failure
Bulkowski reports outcomes that conflict with the traditional continuation labels, so treat continuation as a hypothesis. For a reproducible audit, save the high U and low D across all three candles at candle 3 close. Inspect the next five completed bars. The first close at least one tick above U is an upward outcome; the first close at least one tick below D is a downward outcome. This is an illustrative classification rule, not a tested trading system.
- A downside close of 94.99 followed by 111.01 within five further bars is a confirmed continuation followed by a failure under this audit rule. Keep both timestamps; do not erase the original match.
- An intrabar boundary breach does not satisfy a closing rule. If the chart ends before the observation window does, mark the outcome incomplete instead of classifying it as unconfirmed.
- The gap itself gives no profit target or position size. Orders, stop execution, fees and slippage require a separate strategy specification. A later gap can prevent execution at the intended threshold.
| Outcome within the next five bars | Downside example | Upside example |
|---|
| Continuation | Close <= 94.99, below D = 95 | Close >= 105.01, above U = 105 |
| Opposite-direction breakout | Close >= 111.01, above U = 111 | Close <= 88.99, below D = 89 |
| No eligible close | Record unconfirmed at the end of bar 8 | Record unconfirmed at the end of bar 8 |
Review the exact bars before generating a detector
Use ordinary TradingView candles and preserve the exchange-qualified symbol, timeframe, session and adjustment settings with each example. Heikin-Ashi OHLC is synthetic. If adjacent bars open exactly at the preceding close, their full ranges share a price and cannot satisfy a strict gap. Missing bars or a change in chart settings can also change what appears separated.
- Give Pine Script AI Coding Agent the complete rule sheet, reference window, tick buffer and confirmation timing. Ask for separate rejection reasons and shape versus outcome markers. Inspect the generated source, run syntax validation, compile it in TradingView and compare it with every accepted and rejected example above.
- Upload a readable screenshot to AI Chart Analysis to review the visible trend and candle structure. Include failed examples as well as matches. Check exact OHLC in chart data because an image cannot reliably settle a one-tick boundary or reveal off-screen history.
- Record body gap, full-range gap, closing fill percentage and classification separately. This page provides a written specification and hypothetical cases; it has not executed a detector or measured a trading advantage.