Harmonic Pattern Detector PRZ
- Indicatori
-
Augusto Martin D'anna
Sviluppatore MQL5 e Pine Script | Trader dal 2019 | Validazione di strategie
Da trader so che un robot vale quanto la sua logica. Mi assicuro che il tuo EA faccia esattamente ciò che la tua strategia prevede. - Versione: 1.0
Harmonic Pattern Detector finds Scott Carney's harmonic patterns with objective rules and draws them on the chart: X-A-B-C, the potential reversal zone (PRZ) as a box, and a 0-10 score. Patterns are built only from confirmed swings, so once a pattern is drawn it never moves or disappears.
Patterns
- Gartley (B 0.618 of XA, D 0.786)
- Bat (B 0.382-0.500, D 0.886)
- Alt Bat (B 0.300-0.382, D 1.130)
- Butterfly (B 0.786, D 1.270)
- Crab (B 0.382-0.618, D 1.618)
- Deep Crab (B 0.886, D 1.618)
In every pattern C must retrace 0.382-0.886 of AB, and D must also fall inside the pattern's BC projection band (for example 1.272-1.618 for the Gartley).
What it draws
- X-A-B-C legs and the dotted X-B line, in green (bullish) or red (bearish).
- PRZ box: the zone between the XA level for D, the nearest BC projection level and the AB=CD level. Levels more than 3 ATR away from D are left out, so one far projection does not stretch the zone.
- Label: pattern name, score and state: waiting, PRZ reached, or invalid (price went beyond C before reaching the PRZ).
- Score 0-10: how close B is to the ideal ratio (up to 5), how narrow the PRZ is compared with ATR (up to 3) and whether AB=CD lands inside the PRZ (2). Patterns without AB=CD convergence are marked "!AB=CD".
- Diagnostics panel: how many swing sets were tested and why candidates were rejected (C ratio, B ratio, BC projection, low score), plus how many patterns of each type were accepted. If a pattern you see by eye is not drawn, the panel tells you which rule it failed.
Alerts
- When a new pattern appears (C confirmed, PRZ known).
- When price reaches the PRZ.
- Optional push notifications to the MetaTrader mobile app.
Inputs
- Swing depth (bars on each side of a swing, default 3)
- Ratio tolerance: Strict, Standard or Lenient
- Minimum score to show, bars to scan, maximum patterns drawn
- Each pattern on/off
- Alerts for new patterns and PRZ reached, push notifications
- Diagnostics panel on/off, bullish and bearish colors
Honest note about trading these patterns
We tested the same rules (Standard tolerance) as a trading strategy on US100, US500, XAUUSD and EURUSD, M15 and H1, 2015-2021, with CFD costs: limit entry at D, stop 1-2 ATR beyond D, targets 0.382 and 0.618 of AD (32 tests), and a second round with entry only after a candle closes back beyond D, with and without an EMA 200 trend filter, adding the Cypher (64 tests). None showed a statistically significant edge, and in the second round the results by pattern were close to zero (Bat +0.04 R per trade, Gartley -0.02 R, Cypher -0.10 R). This indicator is a tool to find and measure the patterns objectively, not a buy or sell signal. Combine it with your own analysis and risk management.
Notes
- A swing is confirmed "depth" bars after it forms, so a pattern appears a few bars after its C point. This delay is what makes it non-repainting.
- Works on any symbol and timeframe. On higher timeframes valid patterns are rare; on lower timeframes there are many more.
- It recalculates once per new bar, so it does not slow down the terminal.
