TradingView chart patterns

Rectangle chart patterns: touches, breakouts and failed ranges

A rectangle chart pattern is a sideways price structure bounded by approximately equal swing highs and approximately equal swing lows. Its support and resistance are horizontal and parallel. Two highs and two lows establish a candidate; a defined breakout condition determines its resolution. A prior trend provides context, but the rectangle alone does not select the next direction.

See the decision guide

Identify the box before assigning a direction

StockCharts describes rectangles using at least two comparable reaction highs and two comparable reaction lows. Its discussion allows continuation and reversal outcomes. TradingView also describes the rectangle as directionally uncertain. This page concerns recognition and breakout classification; buying and selling repeatedly inside the range requires a separate entry and exit model.

FeatureRectangle requirementReason to reject or relabel
Upper and lower edgesTwo horizontal price levels, R > SParallel sloping edges describe a channel; converging edges describe a different shape
Independent touchesAt least two highs and two lows from distinct swingsAdjacent candles during one visit are not separate swings
ToleranceEvery selected high is near R and every selected low is near SIncreasing tolerance after a failed touch changes the detector
ContainmentA stated closing-price rule holds until the candidate is availableA breakout already occurred before the last anchor could be known

A four-touch rule with measurable tolerance

The following is an illustrative research specification, not a TradingView default or an optimized setting. Use standard candles on one fixed symbol, timeframe and session. A high must be strictly higher than the highs of three bars on each side; a low must be strictly lower than the lows of three bars on each side. Reject ties. Confirm the swing only after the third right-side bar closes.

  • Use the latest four alternating swings when no candidate is active. Merge consecutive same-type pivots by retaining the more extreme one; for equal prices retain the earlier one. Freeze all anchors once the candidate passes.
  • A later high of 109.50 passes the 0.50 touch band, while 109.49 fails. A zero-height box is invalid. Reject overlapping touch bands by requiring twice the tolerance to be less than H.
  • Do not widen the box when subsequent prices leave it. Additional touches do not restart its clock. An unbroken candidate expires after bar 51; save that outcome and require a later final anchor before creating another candidate.
  • These bar counts and price bands define a testable sample. Changing the timeframe or tolerance creates a different sample and requires a fresh comparison.
RuleExact definitionHypothetical example
Swing sequenceFour alternating confirmed swings, starting with either type; neighboring anchors 4 to 12 bars apartHigh 110 at bar 10, low 100 at 16, high 109.8 at 22, low 100.2 at 28
Frozen boundariesR = first high; S = first low; height H = R - S must be positiveR = 110; S = 100; H = 10
Touch bandMaximum absolute distance from the relevant boundary is 5% of H, inclusiveTolerance = 0.50; later touch errors are 0.20 and 0.20
ParallelismBoth saved boundaries have zero slope; do not join drifting highs or lows with sloped linesR(t) = 110 and S(t) = 100 on every active bar
Formation closesAll closes from the first anchor through confirmation stay in [S - 0.20, R + 0.20]Every close from bars 10 to 31 is assumed within [99.80, 110.20]
Availability and expiryStart on the bar after the final pivot confirms; allow 20 completed bars for a breakFinal pivot confirms at 31; eligible breakout bars are 32 through 51

Separate a wick, a closing break and a failed break

For this example, the first completed close strictly above R + 0.20 or strictly below S - 0.20 is the breakout event. The 0.20 buffer is 2% of H and is separate from touch tolerance. Start checking at bar 32, regardless of earlier intrabar excursions. Consume the candidate after its first event so repeated outside closes cannot create repeated breakout signals.

  • Track early failure over the five bars after the event: an inside close or a close beyond the opposite buffered edge qualifies. Apply the mirror rule after a downside event. A later return is logged separately, not silently discarded.
  • A successful retest can touch the broken edge intrabar and still close outside it. Specify a retest entry separately if needed; a breakout need not retest at all.
  • A signal can gap past the threshold. The threshold is not an execution price. This event model has no trade orders, stops or profit calculation.
Alternative path after bar 31TestRecorded result
High reaches 110.70; close is 109.90Close does not exceed 110.20Wick excursion; no upside event
Close is exactly 110.20Equality fails the strict comparisonNo event
Bar 32 closes at 110.40110.40 > 110.20Upside breakout
Bar 32 closes at 99.6099.60 < 99.80Downside breakout
Upside break at 32; close at 34 is 109.60Close returns to [100, 110] within the next five barsEarly failed upside break under this custom rule
Upside break at 32; close at 34 is 99.60Close crosses the opposite buffered edge, below 99.80Opposite-side failure, even though no close landed inside the box
No qualifying close through bar 51Twenty eligible bars have elapsedExpired rectangle

Continuation and reversal describe context, not geometry

Save the preceding-trend label before the breakout. For a reproducible example, compare the close immediately before the first anchor with the close 20 bars earlier: label a positive difference up, a negative difference down, and equality flat. This simple label is a chosen context proxy and does not measure trend quality. Missing history is unknown, not flat.

  • The same 100-to-110 box has height 10. A conventional height projection gives an upside reference of R + H = 120 or a downside reference of S - H = 90. It does not use the eventual entry fill.
  • Neither reference is a forecast, a guaranteed fill or a measured success rate. Review events that never reach it, including the early failures above. Record commission, slippage and exit rules before turning this study into a strategy.
  • Keep volume as a separate recorded field or an explicit optional filter. StockCharts notes that rectangle formation volume is not uniform; volume contraction is not a universal recognition requirement.
Prior contextUpside breakDownside break
UpContinuation candidateReversal candidate
DownReversal candidateContinuation candidate
Flat or unknownUpward range resolutionDownward range resolution

Distinguish TradingView drawings from automatic detection

The Rectangle drawing tool lets you mark a chart region and set coordinates. The automatic Chart Pattern Rectangle indicator uses 5/5 pivots, confirms breaks by closing price, and expresses permissible deviation as a percentage of rectangle height. Its In Progress mode can use unconfirmed final points. These are different mechanisms from the custom three-right-bar specification above.

  • TradingView defines its Failed status using a move beyond the last opposite rectangle point before reaching the target. The five-bar return-inside label on this page is a separate research definition; do not compare those labels as if they were identical.
  • A pivot drawn on bar 28 is only available on bar 31 under this example. Keep anchor time, confirmation time and breakout time in separate fields. Backdating a marker does not make the signal available earlier.
  • Closing-bar evaluation avoids reacting to an unfinished candle that later moves back. It does not remove every repainting cause, including revised source data. Save events as they occur rather than counting only shapes still visible later.

Review the anchors, then draft the objective alerts

Pineify AI Chart Analysis accepts a chart screenshot and returns analysis that includes support and resistance. Keep the symbol, timeframe and price axis visible. Compare the output with your manually recorded four anchors, tolerance and invalidation rules. An image interpretation cannot prove exact touch counts or reconstruct missing candles.

  • Record each proposed anchor as a bar time, price and confirmation time. Mark uncertain readings explicitly; verify prices against chart data before accepting the candidate.
  • Give Pine Script AI Coding Agent the frozen levels, swing definition, tolerance, breakout buffer, expiry and failure window. Ask it to draft closing-bar alerts and distinct events for creation, breakout, failure and expiry.
  • Inspect and syntax-check the resulting script, then replay the worked paths above on TradingView. The agent can draft code; agreement with your intended detector still needs review. This page provides a recognition specification, not a ready-to-run script or live scanner.
Where Pineify fits

AI Chart Analysis

Upload a chart screenshot to review support and resistance, then verify the proposed rectangle anchors against the chart. Image analysis can miss or misread prices and does not certify the pattern.

Also useful: Pine Script AI Coding Agent. Draft alert logic from your explicit rectangle rules. Review generated code, confirmation delays and failure events before using it on TradingView.

Review a chart screenshot

Frequently asked questions

Educational information, not investment advice. All prices, thresholds and paths are hypothetical. No live signals, backtest results or measured success rates are presented. Pattern recognition and AI-generated code do not guarantee trading profits.

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.