Concept
Doji
Doji, also known as long-legged, four-price variants, is a Chart & Candlestick Patterns concept. The Library holds 1 implementation, a working definition you can pull into Quant.
Top Doji indicator
The top custom implementation, built on the original standard Doji formula.
1 total
Want to trade Doji? The implementation below is one prompt away from a backtested strategy in Quant.
What is a Doji?
A doji is a candlestick whose open and close land at, or almost at, the same price, collapsing the real body to a thin line while the shadows record the session's full travel. In candlestick vocabulary it is the indecision candle: both sides moved price during the period, but neither side held the gain by the close. Wick structure defines the variants. A long-legged doji has long shadows on both sides; a dragonfly doji opens and closes near the high above a long lower shadow; a gravestone doji opens and closes near the low beneath a long upper shadow; the rare four-price doji prints when all four prices are equal, usually on very thin trading.
A doji carries little information on its own; its weight comes from location. After a sustained advance or decline it shows the trend failed to extend into the close, which is why candlestick tradition treats it as an early trend exhaustion warning rather than a reversal signal in itself. Inside a quiet range, near-zero bodies are routine and mean little. 'Nearly equal' is also a judgment call: coded detectors typically require the body to be a small fraction of the high-low range, and the exact threshold is a convention that varies by source, so two scanners can disagree about the same candle.
How to identify a Doji
Recognition reduces to a body-to-range comparison plus context.
- 1Compare open and close. The real body should be a small fraction of the candle's total high-low range; exact thresholds are conventions, so make yours explicit and consistent if you code it.
- 2Classify the variant from the shadows: long on both sides (long-legged), lower shadow dominant with the body at the top (dragonfly), upper shadow dominant with the body at the bottom (gravestone).
- 3Weigh the location. A doji after an extended leg or at a tested S/R zone is a meaningful stall; a doji in the middle of a quiet range is noise.
- 4Wait for the next candle. Direction comes from the confirmation bar, not the doji itself: a decisive close away from the doji's range is the usual trigger.
How traders use it
- As a stall warning inside trends: a doji after a directional leg says the last push found no acceptance, prompting tighter stops or partial profit-taking rather than an immediate counter-trend entry.
- As the hinge of multi-candle reversal patterns: the morning star and evening star build around a small-bodied middle candle, a doji in their 'doji star' variants, and a doji as the second candle of a harami is read as a 'harami cross'.
- At levels: a doji forming at support, resistance, or a prior swing extreme frames a contested auction, and traders commonly set triggers beyond the doji's high and low so the market picks the direction.
- In scanners and scoring systems: because the definition reduces to a body-to-range ratio, doji detection is cheap to code and usually serves as one confluence input among several rather than a standalone signal.
Doji vs similar patterns
Spinning Top: A spinning top has a small but clearly visible real body between two shadows; a doji's open and close are essentially equal. Both read as indecision, with the doji the more extreme statement of it.
Hammer: A hammer keeps a real body at the top of the range above a long lower shadow and appears after a decline; the dragonfly doji is its no-body cousin. Both describe rejection of lower prices, but the hammer's definition requires the downtrend context.
Harami: A harami is a two-candle containment pattern: a small real body inside the prior candle's body. A doji is a single candle; when the contained second candle is a doji, the combination is called a harami cross.
Concept family
Chart & Candlestick Patterns
84 concepts mapped · 84 in the Library
Doji FAQ
Turn Doji into a trading strategy.
Take the implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it in conversation.
