# Doji

Also known as: long-legged, four-price variants.
A Chart & Candlestick Patterns concept (Candlestick catalog) in the LuxAlgo Library, with 1 indicator implementation.

## 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](https://www.luxalgo.com/library/concept/trend-exhaustion/) warning rather than a [reversal](https://www.luxalgo.com/library/concept/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.

1. Compare 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.
2. Classify 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).
3. Weigh the location. A doji after an extended leg or at a tested [S/R zone](https://www.luxalgo.com/library/concept/s-r-zone/) is a meaningful stall; a doji in the middle of a quiet range is noise.
4. Wait 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](https://www.luxalgo.com/library/concept/morning-star/) and [evening star](https://www.luxalgo.com/library/concept/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** (https://www.luxalgo.com/library/concept/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** (https://www.luxalgo.com/library/concept/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** (https://www.luxalgo.com/library/concept/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.

## FAQ

### Is a doji bullish or bearish?

Neither on its own. A doji records a session that closed where it opened, which is indecision, not direction. The lean comes from context: after a long advance it hints the uptrend stalled, after a decline it hints selling pressure faded. Most candlestick practice requires the next candle to confirm before acting on it.

### What are the types of doji?

Four are commonly named. The long-legged doji has long shadows on both sides, maximum indecision. The dragonfly closes near its high above a long lower shadow and leans bullish at lows. The gravestone closes near its low beneath a long upper shadow and leans bearish at highs. The four-price doji, where open, high, low, and close all match, mostly appears on illiquid symbols.

### How small does the body have to be for a doji?

There is no universal number. Candlestick literature says the open and close should be virtually equal, and coded detectors translate that into a maximum body-to-range ratio. The threshold is a convention that varies across sources and platforms, which is why different scanners can label the same candle differently. Whatever cutoff you choose, apply it consistently.

## Implementations in the Library

- Candlestick Structure (LuxAlgo): https://www.luxalgo.com/library/indicator/candlestick-structure/

## Related concepts

- Hammer: https://www.luxalgo.com/library/concept/hammer/
- Bullish/bearish Engulfing: https://www.luxalgo.com/library/concept/bullish-bearish-engulfing/
- Shooting Star: https://www.luxalgo.com/library/concept/shooting-star/
- Gravestone Doji: https://www.luxalgo.com/library/concept/gravestone-doji/
- Dragonfly Doji: https://www.luxalgo.com/library/concept/dragonfly-doji/
- Spinning Top: https://www.luxalgo.com/library/concept/spinning-top/
- Marubozu: https://www.luxalgo.com/library/concept/marubozu/
- Hanging Man: https://www.luxalgo.com/library/concept/hanging-man/
- Inverted Hammer: https://www.luxalgo.com/library/concept/inverted-hammer/
- Harami: https://www.luxalgo.com/library/concept/harami/

---

Source: https://www.luxalgo.com/library/concept/doji/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/