15 — Bilateral & Wedge

Rectangle#

RangeHeuristic1 min read
◆ The PatternHorizontal support and resistance — a consolidation box

The Rectangle is a horizontal consolidation range — price bounces between parallel support and resistance. It's a pause in the trend. Breakout direction usually follows the prior trend. The measured move is the rectangle's height.

Target = Breakout ± Height of rectangle
Can be traded internally (buy support, sell resistance) or by waiting for the breakout.
// Rectangle — horizontal range
Key insight: The longer a rectangle persists, the more significant the eventual breakout — energy is building up like a compressed spring.
Pattern bridge: Price oscillating between two fixed bounds is a uniform distribution in action. In ML, batch normalization constrains activations to a bounded range.
Worked example

Three highs at 110 and three lows at 100: a 10-point range. Day 27 closes at 112, above the top; the target is 110 + 10 = 120.

The example data

The turning points the daily closes run through, in straight lines between them; high and low are half a point either side of each bar.

DayClose
0100
4110
8100
12110
16100
20110
24100
27112
Where it misleads
  • Inside the range the opposite trade works — sell the top, buy the bottom — so breakout and range traders take turns being wrong until it breaks.
  • Breaks that return into the range are common; many traders wait for a second close outside it.
  • Each test of an edge is also read as weakening it, so the same history supports both “it will hold” and “it will break”.
In code
def swings(s, n=3):                     # a swing high (low) is the extreme of the 2n+1 bars around it
    w = s.rolling(2 * n + 1, center=True)
    return s[s == w.max()], s[s == w.min()]
c = df['close']
highs, lows = swings(c)
top, bottom = highs.iloc[-3:].mean(), lows.iloc[-3:].mean()
flat = highs.iloc[-3:].std() / top < 0.01 and lows.iloc[-3:].std() / bottom < 0.01
height = top - bottom
breakout = c.iloc[-1] > top
target = top + height
Python, in your browser — edit the code and run it again

Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns open, high, low and close for the data above.

Sources
  • Encyclopedia of Chart Patterns (2nd ed.), T. N. Bulkowski, Wiley, 2005 — success and failure rates from large counts of patterns
  • Technical Analysis of Stock Trends, R. D. Edwards & J. Magee, 1948 (later editions revised by W. H. C. Bassetti)

Last reviewed October 2026 · How this site checks its content · Report a mistake

Linked from 1
← Previous
Broadening Formation
Open in the full reader, with the topic sidebar