Define how close the body must be to the low
TradingView describes a doji near the low with a long upper shadow, but its support article does not specify a universal percentage cutoff. The following is a custom, illustrative definition for ordinary OHLC candles. Let O, H, L and C mean open, high, low and close, and let R = H - L. Reject a zero-range candle before dividing by R.
- All conditions must pass. The endpoint rule already implies an upper shadow of at least 90%; the 80% rule is retained as an independent input if the endpoint tolerance is later widened.
- Example: O = 100.10, H = 104.00, L = 100.00 and C = 100.05. R is 4.00; the body is 1.25%, the highest body endpoint is 2.5% above the low, the upper shadow is 97.5%, and the lower shadow is 1.25%.
- These percentages are assumptions, not TradingView defaults or tested optimal settings. A candle with a 7% body fails this example even if it looks like a doji on a compressed chart.
- For instruments with coarse ticks, a one-tick change can cross a percentage boundary. Record the tick size and avoid silently rounding a failed candle into a match.
| Measurement | Calculation | Illustrative requirement |
|---|---|---|
| Small body | Absolute difference between C and O, divided by R | At most 5% |
| Both endpoints near the low | (max(O, C) - L) / R | At most 10% |
| Long upper shadow | (H - max(O, C)) / R | At least 80% |
| Lower shadow | (min(O, C) - L) / R | At most 5% |