The doji is a candle where the open and close are virtually the same, creating a cross-like shape. It represents indecision between buyers and sellers. While not a strong directional signal on its own, a doji at a key level after a strong move can precede significant reversals.
There are several doji variants, each telling a slightly different story:
The usual systematic rule is that the body must be ≤ 5% of the bar's total range:
``` isDoji = math.abs(close - open) <= (high - low) * 0.05 and barstate.isconfirmed ```
This threshold is what distinguishes a doji from a spinning top (small but visible body, typically 5–30% of range) and from a hammer or shooting star (small body up to ~35% of range, distinguished by wick asymmetry). The 5% threshold is not universal — some systematic traders loosen it to 10% for intraday charts where true zero-body bars are rare — but 5% is the cleanest default for daily and higher timeframes.
With that rule you can also mechanically detect the sub-variants:
A doji by itself is not a trade signal. It is a warning that the balance of power between buyers and sellers has shifted to equilibrium. The candle that follows the doji is what confirms direction.
The practical approach to doji trading:
Doji candles are most useful as filters rather than triggers. For example, you might avoid entering a trend-following trade if a doji has just formed, suggesting momentum is fading.