Concept

Rectangle

Rectangle, also known as box, Darvas box, is a Chart & Candlestick Patterns concept. The Library holds 1 implementation — a working definition you can pull into Quant.

Top Rectangle indicator

The top custom implementation, built on the original standard Rectangle formula.

1 total

From studying Rectangle to trading it: take the implementation below into Quant and backtest it instantly.

What is a Rectangle?

A rectangle is a consolidation bounded by two roughly horizontal, parallel lines: price oscillates between a flat ceiling and a flat floor, with classical convention asking for at least two touches of each boundary before the pattern earns the name. It is the chart-pattern formalization of a trading range, and the box variants popularized by Nicolas Darvas in the 1950s treat each completed rectangle as a building block in a trending stock.

The pattern has been in the canon since the earliest chart-pattern taxonomies, where it was catalogued alongside triangles as the basic sideways formation, and it acquired its most famous variant when Darvas described his box method in the 1960 bestseller about running his stock account up while touring as a dancer. The box's appeal was always its objectivity: a ceiling proven by failed pushes, a floor proven by held dips, and a rule for what to do when either gives way.

Rectangles resolve by breakout. Classical texts file them under continuation patterns because the break tends to go with the prior trend, but the boundaries carry no directional obligation and either side can give way. The standard measure rule projects the box's height from the breakout level to set a minimum objective.

What happens inside the box is the analytical question. A rectangle is two-sided by definition, sellers defending the ceiling, buyers the floor, and the volume pattern (conventionally contracting through the range, expanding on the resolution) plus the character of each boundary test hint at which side is absorbing. The pattern's known failure modes are the false breakout that traps one side before the real move goes the other way, and the slow bleed where a range simply dissolves into drift without ever resolving cleanly.

How to identify a rectangle on a chart

The boundaries must be proven by touches, not drawn by hope.

  1. 1Find a consolidation whose highs stall repeatedly at one level and whose lows hold repeatedly at another, with at least two genuine touches per boundary.
  2. 2Check the boundaries are roughly horizontal and parallel; sloping boundaries belong to channels and wedges, converging ones to triangles.
  3. 3Watch volume behavior: conventionally it contracts inside the box and expands on the resolution, so a quiet interior with busy boundary tests fits the pattern.
  4. 4Measure the box height at formation; that is the measure-rule projection base for the eventual break.
  5. 5Take the resolution on a decisive close beyond a boundary, not on an intrabar poke, and treat re-entry into the box as the failure signal.
  6. 6Grade the context: a rectangle after a strong advance resolving upward is the textbook continuation; the same box at a long-term top or bottom can be the reversal structure instead.

How traders use it

  • Breakout trading: enter on a close beyond a boundary, target the box height projected from the break, and invalidate on a return inside the range; a failed break that falls back into the box is a standard cue to stand down or reverse.
  • Range trading inside wide rectangles: fading the floor and ceiling while the box holds, with the known failure mode that the rotation which ends in a breakout stops out whoever faded it.
  • Darvas-style trend following: in an uptrend, each new box forming above the previous one is read as continuation; entries go on the break of the box top with a stop under the box low, ratcheting upward as new boxes stack.
  • Reading the interior lean: a partial rise that fails to reach the ceiling before rolling over, or a partial decline that never tests the floor, is a documented tendency toward the opposite boundary breaking, and traders use those incomplete rotations as an early bias read.
  • Triggering off boundary candles: bar-level signals at the edges, a pin bar rejecting the floor or an engulfing bar at the ceiling, give range traders defined entries and stops inside the larger box logic.

Rectangle vs. neighboring patterns

Trading Range: Trading range names the market condition of two-sided rotation; rectangle is the drawn pattern, with touch conventions, boundary lines, and a measure-rule target attached.

Bull/bear Flag: Flags are brief pauses that slope against the preceding impulse; rectangles are horizontal, typically last longer, and need not sit on a flagpole.

Ascending/descending/symmetrical Triangle: Triangles have at least one converging boundary, so the range narrows toward an apex; a rectangle's boundaries stay parallel and the range width holds.

Concept family

Chart & Candlestick Patterns

84 concepts mapped · 84 in the Library

Rectangle FAQ

Is a rectangle pattern bullish or bearish?

Neither by construction. Classical literature treats rectangles as continuation patterns, meaning the break is expected in the direction of the prior trend, but that is a tendency rather than a rule. Both boundaries are live until one breaks, which is why most traders trade the resolution instead of predicting it.

What is a Darvas box?

Nicolas Darvas's 1950s method drew a box around each consolidation in a rising stock: a ceiling confirmed by failed attempts to exceed it and a floor confirmed by holding lows. He bought when price broke above the current box, trailed a stop beneath it, and added as new boxes formed higher. The Darvas box is a trend-following application of the rectangle's horizontal-boundary logic.

How long can a rectangle last?

From a few bars to many months; the pattern has no expiry, and long rectangles on weekly charts are classic bases. Duration cuts both ways: a longer box builds a larger measure-rule target and traps more positioning, but it also raises the odds that the eventual resolution matters structurally. What ends the pattern is acceptance beyond a boundary, not the calendar.

What should volume do inside a rectangle?

The classical description has activity contracting as the range matures and expanding on the breakout, with boundary tests busier than the interior drift. It is a consistency check rather than a requirement: 24-hour markets and index products blur the read, and rectangles resolve validly without textbook volume. A breakout on conspicuously dead volume, though, earns extra suspicion of failure.

How is a rectangle different from a double top or bottom?

Touch count and intent. A double top or bottom is two tests of one extreme with a reversal thesis attached; a rectangle needs both boundaries proven and carries no directional thesis until it resolves. Many developing double tops become rectangles when the 'neckline' holds and price keeps rotating, which is why chartists often wait for the structure to declare itself.

What are partial rises and partial declines?

Incomplete rotations inside an established rectangle: a partial rise leaves the floor but rolls over before reaching the ceiling, and a partial decline mirrors it from above. Pattern-statistics work catalogued them as leans, with the failed rotation tending to precede a break through the opposite boundary. They are read as evidence of one side absorbing, useful for bias but still requiring the actual breakout for confirmation.

Turn Rectangle into a trading strategy.

Take the implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it with AI.