Wedge And Triangle Detector
A wedge or triangle is defined by the relationship between two trendlines, not by either one alone. This indicator fits the upper line through the two most recent confirmed swing highs and the lower line through the two most recent confirmed swing lows, converts both slopes to price-change-per-bar so the comparison means the same thing on any timeframe or instrument, and classifies the pair against a small, explicit rule set: one line flat with the other angled is a triangle, both angled the same direction with one steeper is a wedge, both angled toward each other is a symmetrical triangle. The check that matters most is the one many naive versions skip: whether the two lines are actually converging. Two lines that both happen to slope upward are not automatically a rising wedge if the lower line is rising faster than the upper - that pair is diverging, not narrowing, and calling it a wedge would be wrong. This indicator computes exactly where (in bars ahead) the two lines would meet and rejects the classification entirely if they do not converge within a reasonable distance, so only shapes that are actually narrowing toward an apex get named. Both lines and the classification label are recalculated only when a new swing confirms, matching the update rhythm of AutoChannel elsewhere in this catalogue. This is a structural read, not a trade signal - there is no buy or sell arrow here, only a picture of the current converging shape and its name, which necessarily updates as new swing information replaces old. Notes and limitations - Uses only the two most recent swing highs and two most recent swing lows on each side - it is not a best-fit regression through more points, which keeps the geometry simple and matches how a chart reader eyeballs a wedge with a ruler. - The apex projection is exactly that - a projection. Price frequently breaks out of a converging shape well before the lines would have met, which is normal and not a fault of the indicator. - No breakout signal is generated; this indicator identifies and names the shape only. Pair it with a breakout or momentum tool for an actual trigger. - A shape can disappear from one bar to the next if a fresh swing changes which two points define a line - this is a live structural read, not a fixed pattern once drawn.
Indicator · MT4 · v1.0 · Free
About Wedge And Triangle Detector
Wedge And Triangle Detector is an indicator for MetaTrader 4 based on ATR. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Swing bars, Atr period and Flat slope atr. MQL source code included.
Files in the download: WedgeTriangle.ex4, WedgeTriangle.mq4, WedgeTriangle.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Swing bars | 5 | Bars each side required to confirm a swing |
| Atr period | 14 | ATR period used to judge "flat" and convergence |
| Flat slope atr | 0.05 | Slope below this (ATR per bar) counts as flat |
| Max apex bars | 500 | Reject a shape whose lines would only meet beyond this many bars ahead |
| Extend bars | 40 | Bars each line is extended past its newest anchor |
| Upper color | clrCrimson | Upper (resistance) line colour |
| Lower color | clrDodgerBlue | Lower (support) line colour |
| Line width | 2 | Line width |
| Alerts | true | Alert once when the classification changes on a closed bar |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Trend · Alerts · ATR · MT4 Indicator · MQL4 Source Code