Dragonfly doji candlestick: tolerances and confirmation
A dragonfly doji candlestick has an open and close near the high, almost no real body, and a long lower shadow. After a decline, it can be a bullish reversal candidate: price recovered from its low, but the candle alone does not establish a new uptrend. Define how close the open and close must be, then keep pattern detection separate from later confirmation.
Key Takeaways
- Use range-based tolerances for a near-zero body. A shadow-to-body ratio becomes undefined when the open equals the close.
- A hammer has a visible small body; a dragonfly doji has nearly equal open and close. The chosen tolerance determines borderline cases.
- A completed candle and a confirmed reversal setup are different events. A later close above the high can still be followed by failure.
Give "near the high" a measurable tolerance
TradingView describes the open and close as at or relatively close to the high. That description does not specify one universal percentage. The table below is an illustrative detector specification for ordinary OHLC candles. Let range mean high minus low, body mean the absolute open-to-close difference, upper shadow mean high minus the higher of open and close, and lower shadow mean the lower of open and close minus low.
| Measurement | Example requirement | Purpose |
|---|---|---|
| Range | Greater than zero | Exclude flat bars before dividing. |
| Body | At most 5% of range | Allow a small open-close difference. |
| Upper shadow | At most 5% of range | Keep the body near the high. |
| Lower shadow | At least 90% of range | Require the long lower tail. |
- Example: open 100, high 100.2, low 96, close 100.1. Range is 4.2, body is 0.1, upper shadow is 0.1, and lower shadow is 4. Both body and upper shadow are about 2.38% of range; the lower shadow is about 95.24%.
- With the same open, high, and low but close 99.8, the body is about 4.76% and upper shadow about 4.76%. It still qualifies, despite closing below the open.
- Keep the instrument tick size in view: a 5% allowance smaller than one tick admits only exact equality. If you add a tick allowance, disclose it because it changes the detector.
Dragonfly doji versus hammer
Both shapes have a lower tail and a body near the top. The distinction is the body: a dragonfly doji returns almost to its opening price, while a hammer has a small but more visible real body. A lower shadow twice the body is not enough to define a dragonfly. With an almost zero body, even a short shadow can pass that ratio.
| Feature | Dragonfly doji | Hammer |
|---|---|---|
| Open versus close | Equal or within a stated doji tolerance | A small real body |
| Lower shadow | Dominates the candle range | Long relative to the body |
| Upper shadow | Absent or very small | Absent or very small |
| Bullish context | A preceding decline plus later confirmation | A preceding decline plus later confirmation |
Choose a trend filter and a confirmation deadline
Geometry can appear in any trend. This example considers a bullish setup only when the three completed candles before the doji have successively lower closes. That is a short decline filter, not proof of a long-term downtrend. A shape inside a range or after an advance does not pass this particular setup, even when it passes the geometry test.
- At the doji close, record its final high and low. At this point only the shape and preceding decline are known.
- For this example, the immediately following candle must close strictly above the doji high without trading below the doji low. A touch or an intrabar break above the high does not confirm.
- If that next candle fails either condition, the setup expires. Do not wait indefinitely and then assign a later rally to the original signal.
- After confirmation, a trade below the doji low invalidates the low-holding premise. Confirmation alone supplies neither an entry fill nor an exit plan.
Failure chart: a break above the high does not hold
In this hypothetical sequence, the prior closes decline from 105 to 103 to 101. The doji passes the geometry rules with a high of 100.2 and low of 96. The next candle reaches 100.8 but closes at 99.4, below 100.2. The intrabar breakout fails the close-confirmation rule, so no confirmed setup exists. The later break of 96 illustrates why a temporary move above the high and a completed confirmation are different observations.
| Bar | Open | High | Low | Close |
|---|---|---|---|---|
| Decline 1 | 107 | 108 | 104 | 105 |
| Decline 2 | 105 | 106 | 102 | 103 |
| Decline 3 | 103 | 104 | 100.5 | 101 |
| Dragonfly | 100 | 100.2 | 96 | 100.1 |
| No confirm | 100.1 | 100.8 | 98.8 | 99.4 |
| Low broken | 99.4 | 99.6 | 95.5 | 96.2 |
Hollow bodies close at or above the open. Filled bodies close below the open.
Illustrative price units authored for this explanation. These are not historical market observations, fills, or performance results.
Failure chart: confirmation can precede a loss
Change the next candle to a close of 101 with a low of 99.6. It now closes above 100.2 and holds above 96, so the stated setup confirms. The following candle trades down to 95.5 and invalidates it. A stop below the doji low would need a specified buffer and execution assumptions; a gap can fill beyond that level. Neither waiting for confirmation nor measuring a long shadow removes this risk.
| Bar | Open | High | Low | Close |
|---|---|---|---|---|
| Decline 1 | 107 | 108 | 104 | 105 |
| Decline 2 | 105 | 106 | 102 | 103 |
| Decline 3 | 103 | 104 | 100.5 | 101 |
| Dragonfly | 100 | 100.2 | 96 | 100.1 |
| Confirmed | 100.1 | 101.4 | 99.6 | 101 |
| Invalidated | 101 | 101.3 | 95.5 | 96.2 |
Hollow bodies close at or above the open. Filled bodies close below the open.
An alternative illustrative path, not a second observed trade. The same doji confirms at the next close, then fails when price crosses its low.
Check when a TradingView marker becomes knowable
On an open realtime candle, high, low, and close can change, so a dragonfly label can appear and disappear before the candle ends. TradingView documents barstate.isconfirmed as true on the closing update of a realtime bar. Evaluating chart-timeframe geometry then fixes the measurements for that bar. Waiting for the next candle to confirm adds a further bar of delay. Plot the confirmation on that later bar rather than backdating the decision to the doji.
- A bar-close gate does not establish that every part of a script avoids repainting. Higher-timeframe requests and historical plotting need separate review.
- Test qualifying candles, rejected borderline candles, expired setups, and confirmed failures. Compare marker timestamps with alert timestamps.
- Keep the market, timeframe, session, tolerances, entry and exit rules, and costs fixed when measuring outcomes. The diagrams here do not estimate a success rate.
Pineify next step
Turn the tolerances into a script you can inspect
Give Pineify AI Coding Agent your body and shadow limits, decline filter, and next-bar confirmation rule. Ask for adjustable inputs and separate shape and confirmation markers. Check the generated script against the two failure paths, including when an alert becomes eligible.
Educational information, not investment advice. The thresholds and chart sequences are hypothetical examples, not backtest results. Trading can result in loss, and confirmation does not guarantee a profitable trade.