TradingView candlestick patterns

Unique three river bottom: definition and TradingView tests

A unique three river bottom is a three-candle bullish reversal candidate after a decline: a long bearish candle, a second bearish candle with a contained body and a lower low, then a small bullish candle. The thinkorswim definition places the third close below the second close. This describes a price pattern, not a confirmed reversal or a buy order.

See the decision guide

Which definition does the detector use?

The thinkorswim reference requires a long first bearish candle, a contained second bearish body with a long lower shadow and a lower low, and a small third bullish candle closing below the second close. TA-Lib also tests the lower low and body containment, but its executable conditions do not require the third close to stay below the second close. Its code requires the third open to exceed the second low and does not check the prior trend.

  • The detector below follows the thinkorswim third-close restriction and adds an explicit trend filter, body-size thresholds and shadow ratio. It is a disclosed research variant, not a replica of either platform.
  • The word harami in a description can mean body containment. It does not make the two bearish opening candles a TradingView Bullish Harami, whose second body is bullish.

An exact OHLC specification

Number the completed candles 1, 2 and 3, oldest first. O, H, L and C mean open, high, low and close. B = abs(C - O). At default settings, M is the mean body of the ten candles immediately before the candle being measured. The measured candle is excluded from its own mean.

  • The ten-bar mean, 0.5 multiplier, two-body lower shadow and three-close decline are example parameters. Changing them changes the sample. The script exposes the first three settings.
  • No condition requires H2 < H1 or L3 >= L2. Body containment does not mean full-range containment. A third candle can trade below the second low and still satisfy these rules if it opens above that low and closes as specified.
  • Use ordinary candles and a consistent symbol, session and adjustment setting. Missing history suppresses detection. The script rejects invalid current pattern OHLC ranges; it assumes valid historical chart data for the averages.
TestRule used by this example
Prior directionThe three closes immediately before candle 1 decrease strictly.
First candleC1 < O1 and B1 > M1.
Second bodyC1 < C2 < O2 <= O1. Only equality at the upper body edge is accepted.
Second low and shadowL2 < L1; C2 - L2 >= 2 × B2.
Third bodyC3 > O3; B3 < 0.5 × M3; O3 > L2; C3 < C2.
ToleranceNo fuzzy price tolerance. Equality fails every strict comparison; it passes <= and >=.
TimingEvaluate the candidate only when candle 3 closes.

Recalculate one complete candidate

These are invented prices in arbitrary units on a 0.25 grid. Assume the ten bodies before candle 1 are all 2.00, with the last three closes at 112, 110 and 108. This supplies the decreasing context and M1 = 2.00. Earlier valid OHLC can have those body sizes; no market performance is implied.

  • The first body is 8 > 2. The second body spans 102 to 104 inside 100 to 108, yet its low is 97 < 99. Its lower shadow is 102 - 97 = 5, at least 2 × 2 = 4.
  • The ten bodies before candle 3 comprise eight old bodies of 2, then bodies of 8 and 2. M3 = (8 × 2 + 8 + 2) / 10 = 2.60, so the third-body limit is 1.30. Its body is 1.00 < 1.30; its open is 98 > 97; its close is 99 < 102. All tests pass.
  • Candle 1 midpoint is (108 + 100) / 2 = 104. Candle 3 closes at 99, well below it. Requiring a morning-star recovery above 104 would reject this candidate.
CandleOpenHighLowCloseBody
1108.00109.0099.00100.008.00
2104.00105.0097.00102.002.00
398.0099.2597.5099.001.00

Near matches that must fail

Each row changes only the stated value or values in the hypothetical candidate. Keep the baseline history and default settings. All modified OHLC tuples remain valid.

  • Boundary inclusion matters: a first-body upper-edge touch O2 = O1 is permitted by the containment test, although other conditions can still reject that candle. A shadow exactly twice the second body passes; a third body exactly 0.5 × M3 fails.
  • Changing only L3 from 97.50 to 96.75 still passes the candidate test. It lowers the full pattern low to 96.75. If your research requires the second candle to remain the lowest, add L3 >= L2 explicitly and label the stricter variant.
ChangeResultFailed condition
L2 = 99RejectThe second low equals the first low; a lower low is required.
O2 = 108.25; H2 = 108.50RejectThe second body extends above O1 = 108.
C2 = 100RejectThe lower body edge equals C1; C2 must be higher.
O2 = 102; C2 = 104RejectThe second candle becomes bullish.
C3 = 98RejectThe third candle becomes a doji.
O3 = 97; L3 = 97; C3 = 98RejectThe third open equals L2; it must exceed it.
O3 = 101.50; H3 = 102.25; C3 = 102RejectThe third close equals C2; it must be lower.
O2 = 105RejectThe second lower shadow is 5 but twice its new body is 6.
Prior closes = 112, 110, 110RejectThe prior-close decline is not strict.

Unique three river versus morning star and harami

TradingView describes Morning Star as a long bearish candle, a short middle candle that gaps down, and a long bullish candle that gaps up and closes above the first body midpoint. Its Bullish Harami has two candles and a small bullish second body inside the preceding bearish body. Those tests cannot substitute for the three-river conditions.

FeatureUnique three river variant hereTradingView Morning StarTradingView Bullish Harami
Candle count332
Second directionBearishShort middle bodyBullish
Second positionBody inside first; low below first lowOpening gap downSmall body contained by first body
Third candleSmall bullish body; close below C2Long bullish body; close above first midpointNo third candle in the definition
What separates the exampleC2 = 102 inside first body; L2 = 97Example lacks midpoint recoveryExample second body is bearish

Pine Script detector with next-bar follow-through

Paste the Pine v6 indicator into TradingView Pine Editor and add it to an ordinary candlestick chart. UTR marks a completed candidate. On the next completed bar only, C records a close above the full pattern high, F records a close below the full pattern low, and E records neither. This one-bar follow-through window is an example test, not part of the named pattern.

  • For the baseline example, U = 109 and D = 97. A next close of 109.25 confirms; 96.75 invalidates; exactly 109 or 97 expires. A wick through either level without a closing break also expires.
  • Outcome markers appear on the bar where the information becomes known. A confirmation two bars later is outside this example window. The script keeps the original UTR mark even if the next bar fails.
  • Choose the candidate alert in TradingView and use Once Per Bar Close. Syntax checking does not prove the detection logic, intrabar execution or profitability; compare the cases above against the actual chart values.
Custom rules: closed-bar candidates, separate next-bar outcomes, no strategy orders.pine
//@version=6
indicator("Unique three river: explicit research rules", overlay = true)
length = input.int(10, "Prior body average", minval = 1)
shortFactor = input.float(0.5, "Third body / average maximum", minval = 0.01, maxval = 1.0)
shadowFactor = input.float(2.0, "Second lower shadow / body minimum", minval = 0.0)
body = math.abs(close - open)
priorMean = ta.sma(body, length)[1]
valid = not na(open) and not na(high) and not na(low) and not na(close) and high >= math.max(open, close) and low <= math.min(open, close)
ready = not na(priorMean[2]) and not na(close[5]) and valid and valid[1] and valid[2]
priorDecline = close[5] > close[4] and close[4] > close[3]
first = close[2] < open[2] and body[2] > priorMean[2]
secondBody = close[1] < open[1] and close[1] > close[2] and open[1] <= open[2]
secondLow = low[1] < low[2] and close[1] - low[1] >= shadowFactor * body[1]
third = close > open and body < shortFactor * priorMean and open > low[1] and close < close[1]
candidate = barstate.isconfirmed and ready and priorDecline and first and secondBody and secondLow and third
patternHigh = math.max(high, math.max(high[1], high[2]))
patternLow = math.min(low, math.min(low[1], low[2]))
confirmed = barstate.isconfirmed and candidate[1] and close > patternHigh[1]
failed = barstate.isconfirmed and candidate[1] and close < patternLow[1]
expired = barstate.isconfirmed and candidate[1] and not confirmed and not failed
plotshape(candidate, title = "Candidate", style = shape.circle, location = location.belowbar, color = color.blue, text = "UTR", size = size.tiny)
plotshape(confirmed, title = "Next-bar confirmation", style = shape.triangleup, location = location.belowbar, color = color.green, text = "C", size = size.tiny)
plotshape(failed, title = "Next-bar invalidation", style = shape.xcross, location = location.abovebar, color = color.red, text = "F", size = size.tiny)
plotshape(expired, title = "Expired after next bar", style = shape.square, location = location.belowbar, color = color.gray, text = "E", size = size.tiny)
alertcondition(candidate, "Unique three river candidate", "Unique three river candidate on a completed bar")

Review exact prices before strategy testing

Use Pine Script AI Coding Agent to adapt the OHLC tolerance, body thresholds or confirmation window. Supply the accepted and rejected cases, inspect the generated source and explicitly request syntax checking. Keep any revised definition separate from this baseline.

  • Use AI Chart Analysis to review screenshots of a match and a near miss. Preserve timestamps and raw OHLC alongside each image: a screenshot cannot reliably settle an exact equality or show off-screen history.
  • Record candidate counts, confirmed, invalidated and expired events. The final candidate in a dataset has an incomplete outcome if the next bar has not closed; do not count it as expiry.
  • A later confirmation can still fail. Entry timing, spread, fees, slippage and exits need separate strategy rules. This page provides a detector and synthetic validation cases, not a backtest or an estimated win rate.
Where Pineify fits

Pine Script AI Coding Agent

Adapt the explicit three-river rules and inspect the generated Pine Script against accepted and rejected OHLC cases.

Also useful: AI Chart Analysis. Upload screenshots to review visible candle context beside exact OHLC values and detector results.

Adapt my three-river detector

Frequently asked questions

Educational information, not investment advice. OHLC values and follow-through outcomes are hypothetical. The research thresholds are disclosed choices; no measured trading advantage or future return is claimed.

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.