# Rectangle

Rectangle detects consolidations bounded by parallel horizontal levels, requiring at least two confirmed swing touches per boundary within an ATR-scaled tolerance. It draws the box with its proven touches, projects the measure-rule target on a decisive breakout close with a volume note, flags failed breaks, and marks partial rises and declines: the interior leans toward one side giving way.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Apr 7, 2026.
- Access: free.
- Concepts: [Rectangle](https://www.luxalgo.com/library/concept/rectangle/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=hqaf3c2cphm69pfcze83n1i0
- Page: https://www.luxalgo.com/library/indicator/rectangle/

**Rectangle** finds the sideways box the classical way: confirmed swing highs clustering into a flat ceiling, confirmed swing lows into a flat floor, each boundary proven by at least two genuine touches within an ATR-scaled tolerance, and no decisive close beyond either side across the formation. Once confirmed, the [rectangle](https://www.luxalgo.com/library/concept/rectangle/) has no expiry (the box extends until a boundary gives way), with the proving touches dotted on the chart.

## How to Trade the Rectangle?

- **Decisive close beyond a boundary**: the breakout label prints with volume as a multiple of its recent average. A conspicuously quiet break earns suspicion.
- **Measured target**: the box height projected from the broken boundary (the classical minimum objective), drawn dotted until reached.
- **Failed breakout**: a close back inside before the objective traps one side; a cue to stand down or consider the reverse.
- **Partial rise / partial decline**: an incomplete rotation, the documented lean toward the opposite side breaking.

Ceiling and floor tests inside the box carry their own alerts, nine in total.

## Rectangle Settings

- **Swing Length** (default 5): bars each side to confirm swing touches.
- **Minimum Touches per Boundary** (default 2): the classical proof standard.
- **Boundary Tolerance** (default 0.5) with **Tolerance ATR Length** (default 14): how far touches may spread and still count as one boundary.
- **Maximum Formation Length** (default 200): the bar span allowed between the first and last touch.
- **Measured Target**, **Mark Failed Breakouts**, **Volume Note on Breakouts** (all default enabled) with **Volume Average Length** (default 20).
- **Partial Rises & Declines** (default enabled) with **Minimum Rotation %** (default 50); style inputs cover colors and touch markers.

## Frequently Asked Questions

### How does a rectangle differ from a triangle?

Boundaries. A rectangle's ceiling and floor are horizontal and parallel, so the range never contracts; [ascending, descending and symmetrical triangles](https://www.luxalgo.com/library/indicator/ascending-descending-symmetrical-triangle/) have at least one sloping boundary converging toward an apex. The tolerance check exists to reject touch clusters that slope.

### Which way does a rectangle break?

The pattern is two-sided by construction: the box stays direction-neutral until it resolves. Classical texts file it as continuation because breaks tend to go with the prior trend, but neither boundary carries an obligation.

### What do partial rises and declines signal?

A rotation that leaves one boundary, travels at least half the box height by default, then rolls over before tagging the other side. Pattern studies document them as a lean toward the opposite boundary breaking, a tilt, not a trigger.

## Related indicators

- [Channel Continuation](https://www.luxalgo.com/library/indicator/channel-continuation/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/channel-continuation.md
- [Bull/bear Flag](https://www.luxalgo.com/library/indicator/bull-bear-flag/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/bull-bear-flag.md
- [Wolfe Wave Detector](https://www.luxalgo.com/library/indicator/wolfe-wave-detector/) (Rising/falling Wedge): markdown at https://www.luxalgo.com/library/indicator/wolfe-wave-detector.md
- [Pennant](https://www.luxalgo.com/library/indicator/pennant/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/pennant.md
- [Half Cup](https://www.luxalgo.com/library/indicator/half-cup/) (Cup & Handle): markdown at https://www.luxalgo.com/library/indicator/half-cup.md
- [Scallop](https://www.luxalgo.com/library/indicator/scallop/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/scallop.md
- [Measured-move Up/down](https://www.luxalgo.com/library/indicator/measured-move-up-down/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/measured-move-up-down.md
- [Gap Fill Breakouts](https://www.luxalgo.com/library/indicator/gap-fill-breakouts/) (Chart & Candlestick Patterns): markdown at https://www.luxalgo.com/library/indicator/gap-fill-breakouts.md

---

Source: https://www.luxalgo.com/library/indicator/rectangle/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
