Rising & Falling Wedge Detector [HexaTrades]Overview
Wedge Detector automatically identifies and draws the two most actionable wedge patterns: the Rising Wedge (bearish) and the Falling Wedge (bullish). It marks each as a converging cone, validates the geometry, waits for a bar-close breakout, then plots a measured-move target and a structure-based stop without repainting the pattern structure.
It is built around quality over quantity: a strict, perfect-shape gate ensures only genuinely converging, textbook wedges appear. Every part of the logic is transparent and tunable. Ideal for swing and intraday traders who trade chart patterns and want an objective, rules-based way to spot wedges and define risk.
What it detects
Rising Wedge( bearish)
Higher highs and higher lows, but the lows rise faster than the highs (the lines converge upward). Signals a likely breakdown confirmed on a close below the lower trendline.
Falling Wedge ( bullish)
Lower highs and lower lows, but the highs fall faster than the lows (the lines converge downward). Signals a likely breakout confirmed on a close above the upper trendline.
How the Indicator Works
- Pivots: confirmed swing highs/lows (locked pivotLen bars after they occur).
- Boundaries: upper line from the two most recent swing highs; lower line from the two most recent swing lows, projected as straight lines.
- Slope & convergence: rising = both up, lows rising faster; falling = both down, highs falling faster (set by Convergence strictness).
- Perfect-shape gate: no crossing inside, real narrowing, minimum contraction, apex ahead, sensible duration, minimum ATR height.
- Forming preview: dashed shaded cone while developing.
- Breakout: bar-close below lower line (rising → bearish) / above upper line (falling → bullish).
- Filters: optional EMA trend, volume, breakout-candle ATR size.
- Targets/stops: measured-move target + opposite-boundary stop, drawn as persistent right-extending lines.
Features
- Automatic detection of rising & falling wedges from confirmed pivots.
- Perfect-shape validation rejects crossing, barely-narrowing, diverging, past-apex, too-small or too-long shapes.
- Forming preview dashed shaded cone before breakout.
- Bar-close breakout confirmation, no intrabar fakes.
- Measured-move target + structure stop (opposite boundary).
- EMA trend filter, volume filter, breakout-candle ATR filter (all optional).
- Theme-aware dashboard + shaded wedge zone + 3 alerts.
Dashboard
Status: Forming while developing → Confirmed on breakout
Last wedge: Rising Wedge / Falling Wedge
Bias: Bearish / Bullish
Target: Projected take-profit level
Stop: Structure-based invalidation level
Filters: EMA / Volume / ATR shown as On / Off
Settings
Detection:
Pivot length: swing sensitivity. Lower = more (and smaller) wedges.
Min wedge height (ATR): rejects wedges smaller than this many ATR.
Convergence strictness: how strongly the lines must converge (higher = stricter).
Min width contraction: minimum narrowing from start to breakout.
Max wedge duration: rejects over-stretched patterns.
Show forming wedge: preview wedges before breakout.
Filters:
EMA trend filter: only confirm breakouts aligned with the EMA (falling wedge above EMA, rising wedge below).
Volume confirmation: requires above-average volume on the breakout candle.
Min breakout candle size: require a breakout candle of at least N×ATR.
Visuals
Toggle target/stop lines, colors for bullish/bearish / forming, and the dashboard.
Alerts:
Rising Wedge breakdown:bearish confirmation.
Falling Wedge breakout: bullish confirmation.
Any wedge confirmed - either of the above.
Create alerts with “Once per bar close” for non-repainting behaviour.
Trading Guide
- Identify: dashboard Status = Forming + clean dashed cone.
- Enter: on the bar-close breakout (▲/▼) in the wedge's direction.
- Avoid: when filters reject the breakout, or in choppy ranges.
- Stop: the drawn SL (opposite boundary). Target: the drawn TP (measured move).
- Risk: size so breakout→stop is an acceptable risk; R:R = (TP−entry) ÷ (entry−SL).
Bullish Example (Falling Wedge)
Down-trend forms a dashed falling cone → a candle closes above the upper line → ▲ prints, wedge turns solid green, Status = Confirmed → enter, SL = lower line, TP = breakout + wedge height.
Bearish Example (Rising Wedge)
Up-grind forms a dashed rising cone → a candle closes below the lower line → ▼ prints, wedge turns solid red → enter short, SL = upper line, TP = breakout − wedge height.
Best Markets & Timeframes
Markets: works on crypto, forex, stocks, indices, futures, commodities. Best on liquid instruments with clean swings (the volume filter is most meaningful on stocks/indices).
Timeframes: 5m/15m = more signals, more noise (use stricter filters); 1H/4H = the sweet spot; Daily/Weekly = highest quality, fewer & slower.
We would love to hear your suggestions. If you have ideas for new features, indicators, analytics, or improvements, please share your feedback. Your input helps guide future updates and improve the indicator for all traders.
Wedge pattern detector indicator is for educational and analytical purposes only. It is not financial advice. Trading involves risk. Always use proper risk management and combine this indicator with your own analysis before taking any trade.
インジケーター

Wedge Pattern [UAlgo]Overview
Wedge Pattern is a chart overlay that detects rising and falling wedge formations using strict pivot based rules and a validation engine that enforces classic technical analysis requirements. The script builds two trendlines from confirmed pivot highs and pivot lows, verifies that both boundaries converge toward an apex in the future, and ensures that price remains contained within the wedge until a valid breakout occurs.
The indicator is designed to reduce subjective pattern drawing. It requires a minimum number of touches on each boundary, checks that no candle closes outside the wedge during formation, and treats the wedge as invalid if price breaks in the wrong direction or if the two boundaries collapse into each other. When a breakout is confirmed, the script updates the wedge label and can project a measured target based on the initial wedge width.
This tool is meant for traders who want automatic, rules driven wedge identification with clear status states, breakout confirmation, and optional target projection on the chart.
🔹 Features
1) Pivot Based Wedge Construction
The script identifies swing highs and swing lows using pivot detection. Each confirmed pivot is stored as a Coordinate containing bar index and price. When enough pivots exist, the script forms:
An upper trendline from the earliest required pivot high to the most recent pivot high
A lower trendline from the earliest required pivot low to the most recent pivot low
Pivot Left and Pivot Right control swing sensitivity. Larger values produce fewer but stronger pivots. Smaller values react faster but may include minor swings.
2) Minimum Touch Requirement Per Boundary
A wedge is only considered valid when there are at least a user defined number of pivot touches for both the upper and lower boundary. This aligns with standard charting practice where two points draw a line, but three points validate it.
Min Touches per Line controls the minimum pivot count required before a wedge can be formed.
3) Objective Wedge Type Classification
After calculating slopes for the upper and lower trendlines, the script classifies wedge type using slope direction and relative steepness:
Rising wedge requires both slopes to be positive and the lower slope to be steeper than the upper slope
Falling wedge requires both slopes to be negative and the upper slope to be steeper than the lower slope in the negative direction
This ensures convergence and distinguishes wedges from simple channels.
4) Apex Projection and Future Convergence Rule
The wedge apex is computed as the intersection point of the two trendlines. A valid wedge requires the apex index to be in the future. This confirms that the boundaries are converging and that the pattern is not already expired at detection time.
5) Mandatory Containment Rule During Formation
A core validation rule enforces that no closes occur outside the wedge boundaries while the wedge is forming. If any close is above the upper boundary or below the lower boundary by at least one tick, the candidate wedge is rejected. This prevents premature breakouts from being treated as valid patterns.
6) Live Updating Boundaries
Once a wedge becomes active, the script extends both boundary lines on every bar by updating their end coordinates using the trendline slope. This keeps the wedge aligned with current time and allows breakout checks to remain accurate.
7) Breakout Detection and Status Labeling
The script defines correct breakouts by wedge type:
Rising wedge is bearish biased, so a valid breakout is a close below the lower boundary
Falling wedge is bullish biased, so a valid breakout is a close above the upper boundary
When a valid breakout occurs, the wedge status is updated to BROKEOUT and the label color reflects direction. If price breaks the opposite boundary, or if boundaries collapse, the wedge is marked FAILED.
8) Target Projection Using Measured Move
If enabled, the script projects a target line after breakout. The target distance is based on the wedge width measured near the start of the pattern, then projected from the breakout boundary:
For a rising wedge breakdown, the target is placed below the lower boundary by the measured width
For a falling wedge breakout, the target is placed above the upper boundary by the measured width
A target label prints the projected price level.
🔹 Calculations
1) Pivot Detection and Coordinate Storage
Swing points are detected using symmetric pivots:
float ph = ta.pivothigh(high, INPUT_PIVOT_LEFT, INPUT_PIVOT_RIGHT)
float pl = ta.pivotlow(low, INPUT_PIVOT_LEFT, INPUT_PIVOT_RIGHT)
Confirmed pivots are stored using the pivot right offset so the bar index matches where the pivot actually formed:
if not na(ph)
pivot_highs.push(Coordinate.new(bar_index - INPUT_PIVOT_RIGHT, ph))
if not na(pl)
pivot_lows.push(Coordinate.new(bar_index - INPUT_PIVOT_RIGHT, pl))
Arrays are capped to keep only recent pivot history.
2) Trendline Construction and Slope Calculation
When enough pivots exist, the script picks the earliest required touch and the most recent touch for both highs and lows, then builds trendlines:
Coordinate p1h = pivot_highs.get(pivot_highs.size() - MIN_TOUCHES_PER_LINE)
Coordinate pNh = pivot_highs.get(pivot_highs.size() - 1)
Trendline tl_up = Trendline.new(p1h, pNh, 0.0, na)
tl_up.slope := tl_up.calc_slope()
Slope is defined as:
(this.end.price - this.start.price) / (this.end.index - this.start.index)
The same logic is used for the lower trendline from pivot lows.
3) Wedge Type Rules
Wedge type is derived from slope sign and convergence:
Rising wedge:
if tl_up.slope > 0 and tl_lo.slope > 0 and tl_lo.slope > tl_up.slope
w_type := 1
Falling wedge:
if tl_up.slope < 0 and tl_lo.slope < 0 and tl_up.slope < tl_lo.slope
w_type := 2
This ensures both boundaries move in the same direction while converging.
4) Apex Index Calculation
The apex index is calculated from the line intersection of the two trendlines:
float apex_x = (y2 - y1 + m1 * x1 - m2 * x2) / (m1 - m2)
math.round(apex_x)
A candidate wedge is only accepted if apex index is greater than the current bar index.
5) Containment Validation Using Close Prices
The script checks each bar from the wedge start to the current bar to ensure that close remains within boundaries:
float up_p = this.upper.get_price_at(i)
float lo_p = this.lower.get_price_at(i)
float c_p = close
if c_p > up_p + syminfo.mintick or c_p < lo_p - syminfo.mintick
violated := true
If violated is true, the wedge is rejected.
6) Live Boundary Update and Breakout Checks
For active wedges, end coordinates are updated each bar using the projected boundary price:
line.set_y2(w.upper.line_id, w.upper.get_price_at(bar_index))
line.set_y2(w.lower.line_id, w.lower.get_price_at(bar_index))
Breakout checks use the current close against projected boundary prices:
bool b_up = close > u_p
bool b_dn = close < l_p
Correct breakout:
Rising wedge requires b_dn
Falling wedge requires b_up
Invalidation:
Rising wedge fails if b_up
Falling wedge fails if b_dn
Any wedge fails if upper boundary price is less than or equal to lower boundary price
7) Target Projection
Measured width is derived from the initial distance between boundaries near the start of the wedge, then projected from the breakout side:
float m = math.abs(w.upper.start.price - w.lower.get_price_at(w.upper.start.index))
float t = w.is_rising ? l_p - m : u_p + m
The target line and label are drawn forward a fixed number of bars to provide a clear reference after breakout. インジケーター
