Candlesticks · Single-candle patterns
Long-legged doji: rules, the TA-Lib quirk and real results
How a long-legged doji differs from a plain doji, why TA-Lib flags exactly the same 4,119 candles for both, and how to find the genuinely wide ones.
On this page
- What the textbook pattern looks like
- The exact rules Finabase uses, and why they match the doji
- What a genuinely long-legged session says
- How to confirm it
- Two real examples
- What the data says
- How it compares with similar candles
- An educational outline
- How Finabase shows long-legged dojis
- Frequently asked questions
- Summary
In candlestick literature the long-legged doji is the dramatic cousin of the plain Doji candlestick: meaning, exact rules and what the data shows. Price swings far above the open and far below it during the session, then settles back almost exactly at the starting point. The long "legs" are the evidence of a real fight, and the tiny body says the fight ended in a draw.
There is a catch for anyone using software to find it. In our two-year test on 60 US stocks and ETFs, TA-Lib's long-legged doji detector fired on exactly the same 4,119 candles as its plain doji detector. Not roughly the same: identical, bar for bar. This page explains why that happens, straight from TA-Lib's source code, what it means for the markers you see in Finabase, and how to pick out the wide-ranging sessions the textbook actually describes.
What the textbook pattern looks like
The defining features, in the classical description:
- A doji body. Open and close at, or very nearly at, the same price.
- Long shadows on both sides. The session's high and low are well away from the body, and the total range is large compared with recent candles.
- A meaningful location. Like every doji, it says the most after a sustained move, when the market's previous conviction suddenly gives way to a two-sided battle.
When the body also sits close to the middle of the range, many traders give it a second name, the Rickshaw man candlestick: the centered doji, rules and results. Every rickshaw man is a long-legged doji; not every long-legged doji is a rickshaw man.
The exact rules Finabase uses, and why they match the doji
Finabase runs TA-Lib's CDLLONGLEGGEDDOJI on daily bars. Its test has two parts:
| Condition in TA-Lib | Default setting |
|---|---|
| Doji body | Real body ≤ 10% of the average high–low range of the previous 10 candles |
| Long shadow | Upper shadow or lower shadow longer than the candle's own real body (1.0×) |
| Trend before it | Not tested |
| Output | +100 on every match |
The second line is where the textbook and the code part ways. In TA-Lib's default
settings, "long shadow" (ShadowLong) has an averaging period of zero, which means it is
measured against the candle being judged, specifically its real body, with a factor
of 1.0. A shadow is "long" if it is longer than the body.
Now combine that with the first line. A candle that passes the doji test has, by construction, a very small body. Asking one of its shadows to be longer than that body is asking almost nothing. The test can only fail when both shadows are no longer than the body, which requires the session's whole high–low range to be no more than about three times a body that is already tiny. That is a dead-flat day.
The other surprise is the word "long" itself. Because the comparison is with the body and not with recent ranges, a session can be quieter than the days around it and still be flagged as long-legged. In our sample 3,492 of the 4,012 measured cases (87%) had a high–low range below the average of the previous ten sessions. Only 520 had at least an average range, and only 53 had one at least 1.5 times the average.
So when Finabase marks a long-legged doji, read it as "a doji". If you want the wide, contested session the books describe, check the range yourself.
What a genuinely long-legged session says
When the shadows really are long relative to recent trading, the candle tells a richer story than a quiet doji does. Both sides made a serious attempt. Buyers drove price well above the open and failed to hold it. Sellers drove it well below and failed too. The market spent the day searching for a new level and accepted neither.
After a strong trend, that kind of session suggests the participants who powered the trend now face real opposition. It is not a reversal by itself. It is the moment the trend stops being one-sided. Traders who already hold a position often use it to tighten their risk; traders looking for a turn treat it as the first piece of evidence, not the last.
How to confirm it
Because the candle points in no direction, confirmation means waiting for the market to leave the doji's range:
- A close above the high of a long-legged doji that followed a decline.
- A close below the low of one that followed an advance.
- A range filter you apply yourself: for example, insisting that the doji's high–low range is at least as large as the average of the previous ten sessions. That removes the quiet days TA-Lib lets through.
Two real examples
IBM, July 21, 2026. IBM had fallen 31.2% in ten sessions, including a large gap down. On July 21 it opened at $210.72, reached $214.97, dipped to $209.18 and closed at $210.50. The upper shadow was $4.25 and the lower $1.32 against a 22-cent body, so TA-Lib called it long-legged. Yet the session's $5.79 range was only about half the average of the previous ten. It was a quiet day after a violent fortnight, not a wide battle. The next session closed at $205.77, below the doji's low, which a strict reader would count against a bottom. Then the stock turned: ten sessions after the doji it was 11.7% higher. The candle marked the area of the low, but no rule on this page would have put a trader in near it.
Oracle, July 6, 2026. ORCL had dropped 22.0% in ten sessions. The July 6 candle opened at $144.30 and closed at $143.76, with a high of $145.62 and a low of $141.16. Its range, too, was only about 55% of the recent average. The scanner would have listed ORCL under Bullish that evening. The next session closed at $141.60, inside the doji's range: no confirmation either way. Ten sessions later the stock was 15.6% lower, after trading as low as $120.03. A slide that is still accelerating does not respect a quiet doji.
What the data says
Because the detections are identical, the headline numbers for CDLLONGLEGGEDDOJI are
those of CDLDOJI: 4,119 detections across all 60 symbols, 4,012 with ten sessions of
data after them. The range split is our own cut of the same sample.
| Group | Cases | Higher after 5 sessions | Avg 5-session return |
|---|---|---|---|
| Any trading day (the baseline) | 29,760 | 53.1% | +0.35% |
| Every long-legged doji (TA-Lib) | 4,012 | 53.0% | +0.43% |
| Range below the 10-session average | 3,492 | 53.3% | +0.48% |
| Range at least the 10-session average | 520 | 50.6% | +0.06% |
| Range at least 1.5× the average | 53 | 54.7% | −0.04% |
| Confirmed: next close above the high, from there | 1,248 | 53.8% | +0.42% |
46.8% of the measured cases followed a ten-session decline, so context was split roughly evenly between bottoms, tops and everything in between.
What stands out:
- The detector's output is indistinguishable from the market's average. That is what you would expect from a condition met on 13.8% of days.
- Wide-range dojis did not become a bullish signal. The 520 sessions with at least an average range were higher five sessions later 50.6% of the time, slightly below the baseline. Wide, contested sessions are about uncertainty, and uncertainty cuts both ways.
- The truly long-legged cases are rare. 53 sessions in two years across 60 symbols is too small a sample to conclude anything about them.
How it compares with similar candles
| Pattern | Body | Shadows | TA-Lib detections |
|---|---|---|---|
| Doji | ≤ 10% of average range | Not tested | 4,119 |
| Long-legged doji | ≤ 10% of average range | One shadow longer than the body | 4,119 |
| Rickshaw man | ≤ 10% of average range | Both longer than the body; body near midpoint | 3,133 |
| High-wave candle | Shorter than the average body | Both shadows more than twice the body | 3,876 |
| Spinning top | Shorter than the average body | Both shadows longer than the body | 6,572 |
The High-wave candle: what it means, TA-Lib rules and test results candle is the closest relative in spirit: very long shadows on both sides. It allows a somewhat larger body and requires each shadow to exceed twice that body, so it catches some contested sessions that are not dojis at all. The Spinning top candlestick: meaning, color quirk and real results is the loosest of the group.
An educational outline
This is a way to study the pattern, not a recommendation to trade.
- Filter for width first. Keep only long-legged dojis whose range is at least the ten-session average. On Finabase's markers that removes most of them.
- Require a prior move. A ten-session decline or advance of several percent.
- Let the next close decide. Act only on a close beyond the doji's high (after a decline) or low (after an advance).
- Use the far end as the stop. A wide doji gives a wide stop, so size the position from that distance, not the other way round.
How Finabase shows long-legged dojis
- Chart markers. The Long Legged Doji study marks every
CDLLONGLEGGEDDOJIdetection. Add it next to the Doji study and you will see the two sets of marks land on the same candles. - Scanner. Because TA-Lib always returns +100, the candlestick scanner puts every long-legged doji in its Bullish list (S&P 500 long-legged dojis) and never under Bearish, whatever the trend.
- Signals-tab gauge. Each of the 61 patterns votes from its most recent detection in the last eight bars. Since this one and the plain doji fire together, a single doji gives the candlestick gauge two Buy votes at once, and the Rickshaw man candlestick: the centered doji, rules and results often adds a third. With nothing else firing that is a score of 0.5, a Buy verdict, produced by one neutral candle.
Frequently asked questions
What is the difference between a doji and a long-legged doji?
In the textbook, the long-legged doji has long shadows on both sides and a wide range, while a plain doji only needs the open and close to match. In TA-Lib's default implementation, used by Finabase, the extra condition is so easy to meet that the two detectors flagged the same candles in our data.
Is a long-legged doji bullish or bearish?
Neither. It records a session with heavy two-way trade and no winner. Its implication depends on the trend before it and the close after it. Finabase lists it as bullish only because TA-Lib's output is always positive.
How long do the shadows need to be?
There is no official rule. A practical filter is a high–low range at least as large as the average of the last ten sessions, with both shadows clearly longer than the body. TA-Lib requires just one shadow longer than the body.
Is it the same as a rickshaw man?
A rickshaw man is a long-legged doji whose body sits near the middle of the range. TA-Lib also requires both shadows to be longer than the body, so it flagged 3,133 rickshaw men against 4,119 long-legged dojis in our sample.
Summary
The long-legged doji is meant to capture a wide, hard-fought session that ended where it began. TA-Lib's version measures "long" against the doji's own tiny body, so it matches every doji, and most of its detections are actually quieter than the sessions around them. Across 4,012 measured cases the outcomes matched the market's baseline. On Finabase, treat the marker as a doji marker, check the range yourself if you want the textbook pattern, and remember that the scanner and gauge read it as bullish by construction.
Sources and further reading
- Steve Nison, Japanese Candlestick Charting Techniques (New York Institute of Finance, 1991)
- Thomas N. Bulkowski, Encyclopedia of Candlestick Charts (Wiley, 2008)
- TA-Lib source code — CDLLONGLEGGEDDOJI, CDLDOJI and the default candle settings
- Finabase chart data — daily bars for 60 US stocks and ETFs, 2024-10-30 to 2026-10-29; patterns detected with TA-Lib CDLLONGLEGGEDDOJI