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.

Illustrative tolerances, not TradingView default settings
MeasurementExample requirementPurpose
RangeGreater than zeroExclude flat bars before dividing.
BodyAt most 5% of rangeAllow a small open-close difference.
Upper shadowAt most 5% of rangeKeep the body near the high.
Lower shadowAt least 90% of rangeRequire 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.

Compare geometry before interpreting direction
FeatureDragonfly dojiHammer
Open versus closeEqual or within a stated doji toleranceA small real body
Lower shadowDominates the candle rangeLong relative to the body
Upper shadowAbsent or very smallAbsent or very small
Bullish contextA preceding decline plus later confirmationA 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.

Hypothetical dragonfly doji with failed close confirmation
95.5101.75108Decline 1: open 107, high 108, low 104, close 105Decline 1Decline 2: open 105, high 106, low 102, close 103Decline 2Decline 3: open 103, high 104, low 100.5, close 101Decline 3Dragonfly: open 100, high 100.2, low 96, close 100.1DragonflyNo confirm: open 100.1, high 100.8, low 98.8, close 99.4No confirmLow broken: open 99.4, high 99.6, low 95.5, close 96.2Low broken
OHLC values for Hypothetical dragonfly doji with failed close confirmation
BarOpenHighLowClose
Decline 1107108104105
Decline 2105106102103
Decline 3103104100.5101
Dragonfly100100.296100.1
No confirm100.1100.898.899.4
Low broken99.499.695.596.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.

Hypothetical confirmed setup followed by invalidation
95.5101.75108Decline 1: open 107, high 108, low 104, close 105Decline 1Decline 2: open 105, high 106, low 102, close 103Decline 2Decline 3: open 103, high 104, low 100.5, close 101Decline 3Dragonfly: open 100, high 100.2, low 96, close 100.1DragonflyConfirmed: open 100.1, high 101.4, low 99.6, close 101ConfirmedInvalidated: open 101, high 101.3, low 95.5, close 96.2Invalidated
OHLC values for Hypothetical confirmed setup followed by invalidation
BarOpenHighLowClose
Decline 1107108104105
Decline 2105106102103
Decline 3103104100.5101
Dragonfly100100.296100.1
Confirmed100.1101.499.6101
Invalidated101101.395.596.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.

Frequently Asked Questions