TradingView candlestick patterns

Abandoned baby candlestick: bullish and bearish gap rules

An abandoned baby candlestick pattern is a three-bar reversal setup with a doji completely isolated by gaps from both neighboring candles, including their wicks. The bullish version places the doji below the other candles after a decline; the bearish version places it above them after a rise. A gap between bodies alone does not qualify, and a completed pattern does not guarantee a reversal.

See the decision guide

Measure full candle ranges, not only bodies

Label the candles 1, 2 and 3 in time order. O, H, L and C mean open, high, low and close. TradingView explicitly requires the doji shadows to gap completely beyond the shadows of both outside candles. The inequalities below express that requirement; equality means a touch, not a gap.

  • A body gap compares open/close endpoints. A full-range gap compares highs and lows. Separated bodies can coexist with overlapping wicks.
  • A morning or evening doji star may have a similar three-body arrangement. Apply the two full-range tests before using the abandoned baby name.
  • The doji may close slightly above or below its open. State a numerical tolerance rather than relying on candle color or screen appearance.
  • An island reversal can isolate multiple bars and does not require a single doji. Do not merge all double-gap formations into this pattern.
ConditionBullish abandoned babyBearish abandoned baby
Prior contextA defined decline before candle 1A defined rise before candle 1
Outside candlesBearish candle 1, bullish candle 3Bullish candle 1, bearish candle 3
Middle candleDoji below both neighborsDoji above both neighbors
First full-range gapH2 < L1L2 > H1
Second full-range gapH2 < L3L2 > H3
When knowableAfter candle 3 closesAfter candle 3 closes

Check a bullish example and its bearish mirror

These hypothetical prices demonstrate the geometry, not historical returns. Assume the appropriate prior trend and a mean body size of 3 over the 20 bars before candle 1. Both outside bodies exceed that mean and occupy more than 60% of their ranges. Each doji body occupies 5% of its range, within the illustrative 10% tolerance used below.

  • Bullish gaps: 96 - 95 = 1 and 95.50 - 95 = 0.50. The doji high of 95 remains below both neighboring lows. Candle 3 closes at 102, above the first body midpoint of 100.50.
  • Bearish gaps: 105 - 104 = 1 and 105 - 104.50 = 0.50. The doji low of 105 stays above both neighboring highs. Candle 3 closes at 98, below the first body midpoint of 99.50.
  • Bullish rejection: change only candle 3 low to 94.80. Its body still begins above the doji body, but its wick overlaps the doji range. This is no longer a strict abandoned baby.
  • Boundary rejection: a bullish third low of exactly 95, or a bearish third high of exactly 105, touches the doji range. Both fail. A zero-range middle bar also fails the detector below.
Example and candleOpenHighLowClose
Bullish 11041059697
Bullish 2: doji94959394.10
Bullish 39610395.50102
Bearish 19610495103
Bearish 2: doji106107105105.90
Bearish 3104104.509798

A reproducible Pine Script detector

This custom specification uses a doji body no larger than 10% of its range. Both outside bodies must occupy at least 60% of their ranges and exceed the mean body of the 20 bars before candle 1. The prior close must be below its own 50-bar SMA for bullish signals, or above it for bearish signals. A third close beyond the first body midpoint is an additional confirmation filter. These choices are test assumptions, not TradingView built-in defaults or optimized parameters.

  • Use ordinary OHLC candles. Heikin-Ashi values are synthetic, so applying the same comparisons there tests a different price series.
  • The SMA condition is a simple trend proxy, not proof of a sustained trend. The earliest eligible signal needs 50 prior closes plus the three pattern candles.
  • Create an alert from the relevant condition and select Once Per Bar Close. The script draws on candle 3 without backdating a signal to the doji.
  • This indicator has no orders, stops, sizing or performance calculation. Validate the code and inspect matched and rejected bars before designing a separate strategy.
Pine Script v6: strict gaps, markers on candle 3 at its closepine
//@version=6
indicator("Abandoned baby: strict gap example", overlay = true)

dojiPct = input.float(10.0, "Maximum doji body (% of range)", minval = 0.0, maxval = 20.0)
body = math.abs(close - open)
span = high - low
meanBody = ta.sma(body, 20)
trendSma = ta.sma(close, 50)

// [2] is candle 1, [1] is the doji, and [0] is candle 3.
// Reference statistics end on the bar before candle 1.
referenceBody = meanBody[3]
hasHistory = not na(trendSma[3]) and not na(referenceBody)
hasRanges = span[2] > 0 and span[1] > 0 and span > 0
isDoji = hasRanges and body[1] <= span[1] * dojiPct / 100.0
largeOutside = referenceBody > 0 and body[2] > referenceBody and body > referenceBody
solidOutside = body[2] >= span[2] * 0.60 and body >= span * 0.60
midpoint = (open[2] + close[2]) / 2.0

bullGaps = high[1] < low[2] and high[1] < low
bearGaps = low[1] > high[2] and low[1] > high
bullDirection = close[2] < open[2] and close > open and close > midpoint
bearDirection = close[2] > open[2] and close < open and close < midpoint
priorDecline = close[3] < trendSma[3]
priorRise = close[3] > trendSma[3]

eligible = barstate.isconfirmed and hasHistory and isDoji and largeOutside and solidOutside
bullish = eligible and bullGaps and bullDirection and priorDecline
bearish = eligible and bearGaps and bearDirection and priorRise

plotshape(bullish, title = "Bullish abandoned baby", style = shape.triangleup, location = location.belowbar, color = color.teal, size = size.small, text = "AB+")
plotshape(bearish, title = "Bearish abandoned baby", style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small, text = "AB-")
alertcondition(bullish, "Bullish abandoned baby", "Strict bullish abandoned baby completed")
alertcondition(bearish, "Bearish abandoned baby", "Strict bearish abandoned baby completed")

Why continuous markets and chart settings change the sample

The two strict gaps are restrictive. If each bar opens exactly at the preceding close, adjacent full candle ranges share that price, so the required separation cannot occur. This explains why a strict detector can return few or no examples on continuously traded data; it does not establish a measured frequency for crypto, forex or any exchange.

Data choiceWhat can changeReview rule
Regular versus extended sessionsIncluding pre-market and post-market bars changes the intraday sequence and may fill an apparent session gap.Save the symbol, feed, interval and session with each sample. Do not combine counts across session settings.
Dividend adjustmentTradingView adjusts historical prices to account for dividend payments. Comparisons across an ex-dividend boundary can change.Check the dividend event and adjustment setting before interpreting a gap as a shift in buying or selling.
Splits, feed gaps and missing barsA discontinuity may need a data or corporate-action explanation.Check event markers and the OHLC feed. A chart gap alone cannot establish its economic cause.
Doji tolerance and extra filtersWidening the body tolerance or removing the midpoint test changes the selected observations.Keep each rule set separate. Removing wick-gap conditions creates a different pattern definition.

A valid shape can still produce a failed reversal

Pattern completion and trading success are different observations. For a sample review, one possible failure rule is a later close beyond the isolated doji extreme: below 93 in the bullish example or above 107 in the bearish example. Define an evaluation horizon in advance, such as the next ten completed bars. This is an illustrative research rule, not a recommended stop placement.

  • If the bullish example completes at 102 and later closes at 92.80 within that horizon, retain the original signal and record the subsequent failure. Do not erase it from the sample.
  • A third candle can open with a qualifying gap and trade back into the doji range before closing. It is then a rejected formation, not a completed signal that later failed.
  • Specify entry timing, exits, fees, spread and slippage before calculating returns. A gap through a stop level may prevent execution at the intended price.
  • Rare signals leave small samples. A handful of selected charts cannot establish a win rate, and changing filters after inspecting outcomes can overfit those observations.

Carry the exact rules into Pineify

Give Pine Script AI Coding Agent the two high-low gap comparisons, doji tolerance, historical body baseline, trend proxy and confirmation time. Ask it to keep each filter visible so you can explain why a candle was accepted or rejected. Compare any generated modification with the OHLC examples and rerun syntax validation.

  • For AI Chart Analysis, upload a clear chart with the exchange symbol, timeframe, session and all three candles visible. Ask it to review the candidate and surrounding trend.
  • A screenshot may not resolve a one-tick gap. Verify exact highs and lows in the chart data; visual analysis does not certify these inequalities or predict the next move.
Where Pineify fits

Pine Script AI Coding Agent

Draft or revise a detector from explicit wick-gap rules, then inspect the generated source and chart matches. This guide provides an educational indicator, not a tested trading system.

Also useful: AI Chart Analysis. Review an uploaded chart and its visible context. Confirm exact OHLC gaps separately when the image cannot resolve them.

Draft strict gap rules

Frequently asked questions

Educational information, not investment advice. Prices, thresholds and failure paths are hypothetical. No pattern, alert or AI analysis guarantees a reversal, an executable price or a profit. Historical observations may not persist.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.