Head And Shoulders Scanner
A head and shoulders is five alternating swing points: a shoulder, a trough, a head that clears both shoulders, another trough, and a second shoulder roughly matching the height of the first. This indicator builds its swing list from confirmed fractals - each one only known once the bars either side of it have closed - and compresses same-side runs down to the single most extreme point, which produces a clean, strictly alternating zigzag rather than a noisy list of every local wiggle. The five-point shape is then tested directly against that zigzag: shoulder heights within tolerance of each other, head clearly beyond both by a minimum margin, both scaled to the instrument's own ATR so the same settings behave sensibly across a tight pair and a volatile one. Finding the shape is not the same as calling the pattern finished. A right shoulder completing does not by itself mean anything reliable has happened - plenty of five-point shapes that look right never break down. So this indicator treats a completed shape as a candidate only, draws the neckline joining the two troughs, and waits. The pattern is marked complete - arrow, neckline extended, alert fired - only on the first later bar whose CLOSE trades through the (possibly sloped) neckline. That is the point a discretionary trader reading the chart would actually call it confirmed, and it is also what keeps the marker from ever appearing then being wrong a bar later: once drawn, it is drawn for good. Inverse head and shoulders (the bullish version, built from swing lows) uses the exact mirror of the same logic and is tracked independently, so both directions can have a live candidate at once. Notes and limitations - A confirmed pattern is InpSwingBars bars old at the right shoulder, plus however many bars it took the close to break the neckline after that - this is a structure-confirmation tool, not a same-bar entry trigger. - Only one candidate per direction is tracked at a time; a fresh five-point shape replaces an older unconfirmed one rather than queuing behind it. - The shoulder-symmetry and head-prominence checks are the whole definition used here - there is no volume or time-symmetry test. Some published variants add those; this one keeps to the price geometry a chart reader checks first. - Necklines can slope; the break test evaluates the sloped neckline's price at the exact bar being checked, not a flat extension of either endpoint.
Indicator · MT5 · v1.0 · Free
About Head And Shoulders Scanner
Head And Shoulders Scanner is an indicator for MetaTrader 5 based on ATR. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Swing bars, Shoulder tolerance atr and Head prominence atr. MQL source code included.
Files in the download: HeadAndShoulders.ex5, HeadAndShoulders.mq5, HeadAndShoulders.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Swing bars | 5 | Bars each side required to confirm a swing |
| Shoulder tolerance atr | 0.75 | Max shoulder height difference, as a multiple of ATR |
| Head prominence atr | 0.30 | Head must clear both shoulders by at least this many ATR |
| Atr period | 14 | ATR period |
| Max pattern bars | 400 | Max bars allowed from left shoulder to right shoulder |
| Max wait bars | 200 | Give up waiting for the neckline break after this many bars |
| Show labels | true | Label shoulders, head and neckline |
| Alerts | true | Alert once, on the bar the neckline breaks |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 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: Fractals · Dashboards & Scanners · Buy/Sell Arrows · Alerts · ATR · MT5 Indicator · MQL5 Source Code