TradingView candlestick patterns

Mat hold candlestick pattern: rules and TradingView detection

A bullish mat hold pattern has five candles: a long bullish candle, a small bearish candle whose real body gaps above the first body, two smaller candles pulling back shallowly, and a bullish candle closing above the reaction group. It is a continuation hypothesis in an existing uptrend. The initial body gap distinguishes this definition from rising three methods; a match does not establish future returns.

See the decision guide

Mat hold and rising three methods use different boundaries

TA-Lib implements mat hold with a bullish first candle, a bearish second candle and a bullish fifth candle; candles 3 and 4 can have either color. Their bodies step lower but penetrate only a limited part of candle 1. TradingView describes rising three methods with three small bearish middle bodies inside the first candle range. These definitions should not share a detector merely because both use five candles.

  • A body gap does not require a gap between wicks. If candle 2 low overlaps candle 1 high, the body-gap test can still pass.
  • In the example below, candle 2 body is 111 to 113 while candle 1 high is 111. Its body is not contained in candle 1 range, so it fails that rising-three-methods condition.
  • Some definitions impose additional color or wick restrictions. Keep the source and settings with the pattern label; different signal counts may reflect different rules.
TestMat hold structure used hereTradingView rising three methods description
Second candleBearish body entirely above the first bodySmall bearish body inside candle 1 high-low range
Middle groupThree small bodies; the last two overlap the upper part of body 1Three small bearish bodies within candle 1 range
Fifth closeAbove the highest high of candles 2 to 4Above the close of candle 1
TrendUptrend measured before candle 1Existing uptrend; built-in trend options are configurable

A five-bar specification with explicit thresholds

Number candles 1 through 5 from oldest to newest. O, H, L and C mean ordinary open, high, low and close; B = abs(C - O), bottom = min(O, C), and top = max(O, C). This page uses an illustrative detector: its fixed reference window, body ratios and trend filter are research choices, not TradingView defaults or an exact TA-Lib port.

  • The penetration setting p is constrained to 0.01 through 1.00 in the example code. At p = 0.50, the lower endpoints of bodies 3 and 4 must stay strictly above the midpoint of body 1. Touching the midpoint fails.
  • The initial body gap and final breakout use strict greater-than comparisons. On tick-aligned data, equality fails and the next available tick passes that boundary. No hidden rounding tolerance is applied.
  • Small-body equality passes because the size limit uses <=. Doji candles are permitted in positions 3 and 4 if every positional condition passes. Candle 5 has no additional long-body requirement in this version.
  • Wicks of candles 3 and 4 are not restricted by the penetration rule. A stricter low-price filter would be a separate variant. Reject missing history and malformed OHLC in any external dataset before testing.
StageRequired condition
Reference historyA is the mean body size of the 20 candles immediately before candle 1; A must be positive
Prior uptrendThe five closes immediately before candle 1 rise strictly, oldest to newest
Candle 1C1 > O1 and B1 >= 1.5 × A
Candle 2C2 < O2, B2 <= 0.5 × B1, and bottom2 > C1
Candles 3 and 4Each B <= 0.5 × B1; each bottom < C1 and bottom > C1 - p × B1
Descending bodiestop3 < O2 and top4 < top3
Candle 5C5 > O5, O5 > C4, and C5 > max(H2, H3, H4)
Confirmation timingEvaluate only after candle 5 closes; default p = 0.50

Recalculate an accepted OHLC example

These prices are hypothetical and use a 0.01 tick. Assume A = 4 and five preceding closes of 95, 96, 97, 98 and 99. The long-body threshold is 1.5 × 4 = 6. Candle 1 body is 10, so it passes; the maximum reaction body is 5 and the penetration floor at p = 0.50 is 110 - 0.50 × 10 = 105.

  • Descending body tops are 113, 111 and 109. The third and fourth body penetrations are (110 - 108) / 10 = 20% and (110 - 107) / 10 = 30%; both are below the 50% maximum.
  • Candle 2 low is 110.5, below candle 1 high of 111. This accepted sample has overlapping wicks despite its positive body gap.
  • The fifth close exceeds 114 by 1 price unit. A fifth high above 114 alone would not complete the pattern.
CandleOpenHighLowCloseCheck
110011199110Bullish body 10 >= 6
2113114110.5111Bearish body 2; body gap 111 - 110 = 1
3111112107108Body 3; bottom 108 > 105 and < 110
4109110106107Body 2; bottom 107 > 105 and < 110
5108116107.5115Open 108 > 107; close 115 > reaction high 114

Boundary failures that a detector must reject

Apply each alternative independently to the accepted example. Adjust a high or low as stated to keep valid OHLC. A failed candidate stays outside this detector even if the chart later rises.

  • A pattern can complete and then fail to follow through. If a later candle closes at 104, the original event remains recorded; the later move is a separate outcome, not a reason to erase the historical marker.
  • The five-bar shape does not specify an order price, stop, target or position size. A trade simulation also needs costs, slippage and gap-fill assumptions. No win rate is claimed for this specification.
ChangeResultReason
C2 = 110 and L2 = 109.5RejectBody 2 touches C1; the body gap is zero
C4 = 105 and L4 = 104.5RejectBody bottom equals the 105 penetration floor
C4 = 105.01 and L4 = 104.5AcceptBody bottom is just above 105; body size 3.99 remains below 5
C5 = 114 with H5 = 116RejectThe wick breaks out, but the close only equals the reaction high
C5 = 114.01AcceptThe close exceeds the reaction high by one tick
O5 = 107 and L5 = 106.5RejectThe fifth open equals C4 rather than exceeding it
Prior closes = 95, 96, 96, 98, 99RejectThe five-close trend filter requires strict increases
p = 0.30, original OHLCRejectThe floor is 107 and the fourth body touches it

Pine Script v6 detector for the stated rules

Paste this indicator into TradingView Pine Editor and add it to an ordinary candlestick chart. The MH marker is placed on candle 5, after confirmation. The code uses past bars only, leaves the first 24 bars without enough reference history unmarked, and exposes penetration as an input. It detects this bullish variant only and does not place orders.

  • The baseline is ta.sma(body, 20)[5]: at candle 5 it ends on the candle immediately before candle 1. The trend filter uses those preceding closes at offsets 9 through 5. Neither includes the five pattern candles.
  • Create an alert from Mat Hold confirmed and use Once Per Bar Close. barstate.isconfirmed keeps a developing fifth candle from producing a confirmed marker before its close.
  • A symbol, timeframe, session or adjustment change can change the OHLC sequence and labels. Heikin-Ashi prices are synthetic, so they do not test the same traded-price structure. Keep chart settings with each result.
  • Syntax validation does not establish a trading advantage. Compare the accepted sample and every boundary case, then inspect historical chart matches before adding entry and exit logic.
Illustrative Mat Hold rules, with a fixed 20-bar reference and confirmed fifth bar.pine
//@version=6
indicator("Mat Hold: explicit body rules", overlay=true)
penetration = input.float(0.50, "Maximum body penetration", minval=0.01, maxval=1.00, step=0.01)
body = math.abs(close - open)
bodyBottom = math.min(open, close)
bodyTop = math.max(open, close)
referenceBody = ta.sma(body, 20)[5]
firstBody = body[4]
penetrationFloor = close[4] - penetration * firstBody
historyReady = not na(referenceBody) and referenceBody > 0
priorUptrend = close[9] < close[8] and close[8] < close[7] and close[7] < close[6] and close[6] < close[5]
firstLong = close[4] > open[4] and firstBody >= 1.5 * referenceBody
secondGap = close[3] < open[3] and bodyBottom[3] > close[4]
smallReaction = body[3] <= 0.5 * firstBody and body[2] <= 0.5 * firstBody and body[1] <= 0.5 * firstBody
thirdHolds = bodyBottom[2] < close[4] and bodyBottom[2] > penetrationFloor
fourthHolds = bodyBottom[1] < close[4] and bodyBottom[1] > penetrationFloor
bodiesFall = bodyTop[2] < open[3] and bodyTop[1] < bodyTop[2]
reactionHigh = math.max(high[3], math.max(high[2], high[1]))
fifthConfirms = close > open and open > close[1] and close > reactionHigh
matHold = barstate.isconfirmed and historyReady and priorUptrend and firstLong and secondGap and smallReaction and thirdHolds and fourthHolds and bodiesFall and fifthConfirms
plotshape(matHold, title="Confirmed Mat Hold", style=shape.labelup, location=location.belowbar, color=color.teal, text="MH", textcolor=color.white, size=size.tiny)
alertcondition(matHold, title="Mat Hold confirmed", message="Mat Hold body rules confirmed on {{ticker}} {{interval}}")

Review matches and rejected samples with Pineify

Pine Script AI Coding Agent can help draft changes to the detector from written rules. Supply the OHLC table, body-size ratios, penetration threshold and close-only timing. Ask for an explanation of changed conditions, then compare the output with the same accepted and rejected cases. A change from body lows to wick lows must be documented as a new variant.

  • Use AI Chart Analysis with screenshots of both a match and a near miss to review the visible trend and candle arrangement. Include the symbol, timeframe and candle timestamps.
  • Read exact OHLC from TradingView when deciding equality or a one-tick difference. A screenshot cannot reliably resolve those boundaries, and off-screen reference history may be missing.
  • Record detector version, parameters and chart settings before evaluating outcomes. Only proceed to a strategy test after the plotted matches agree with the intended definition.
Where Pineify fits

Pine Script AI Coding Agent

Adapt the written Mat Hold rules into a draft detector. Review the source and compare accepted and rejected OHLC cases before adding strategy orders.

Also useful: AI Chart Analysis. Review visible candle structure in chart screenshots, then verify exact body and wick boundaries against OHLC data.

Draft my Mat Hold detector

Frequently asked questions

Educational information, not investment advice. Prices and thresholds are hypothetical research examples. A confirmed shape, generated code or AI image interpretation does not guarantee a trading outcome or establish profitability.

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.