Loading…

Diamond Pattern Scanner

A diamond is two patterns in sequence sharing one apex: swing-to-swing amplitude widens for a few swings (exactly like a broadening formation), then narrows back down (exactly like a contracting triangle), with the widest swing sitting genuinely in the middle rather than at either end. It is one of the rarer classical chart patterns precisely because it needs seven confirmed swing pivots to alternate cleanly in this specific expand-then-contract shape, which is why most manual pattern libraries skip it entirely or fold it into "broadening formation, ignore the second half." This indicator scans the same strict fractal swing construction used by this catalogue's other pattern indicators (a same-side run of new extremes collapses to its most extreme point, guaranteeing strict high/low alternation), then measures the six amplitude gaps between seven consecutive swings. It only accepts the sequence as a diamond when the middle gap is the largest of all six AND clears InpMinExpansionRatio against the first gap AND clears InpMinContractionRatio against the last gap - broadening into the apex and contracting back out of it, both required, not just an alternating swing count that happens to widen once. Because the swing/alternation machinery is identical in spirit to BroadeningFormationDetector's, and house style forbids including another project's file, it is reimplemented locally here rather than shared. The apex swing's type decides the label: a diamond completing on a low apex reads as a Diamond Bottom (bullish context), a high apex as a Diamond Top (bearish context), matching how the pattern is conventionally read. Notes and limitations This pattern needs seven confirmed swings to even be evaluated, so on quiet instruments or short histories it can go long stretches without a single signal - that is the pattern being genuinely rare, not the detector being broken. Like the other swing-based detectors in this catalogue, a pivot only confirms InpSwingBars bars after it forms, so identification carries that much built-in lag by design; it does not repaint once plotted. This is a shape detector only: it does not predict the breakout direction out of the diamond and does not manage a trade. Requiring the middle gap to be the strict maximum of all six is a deliberately tight test - real diamonds with a slightly uneven amplitude sequence can fail this check even when they look like a diamond by eye.

Indicator · MT4 · v1.0 · Free

About Diamond Pattern Scanner

Diamond Pattern Scanner is an indicator for MetaTrader 4. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Swing bars, Min expansion ratio and Min contraction ratio. MQL source code included.

Files in the download: DiamondPatternScanner.ex4, DiamondPatternScanner.mq4, DiamondPatternScanner.txt.

Settings

SettingDefaultWhat it does
Swing bars5Bars each side required to confirm a swing
Min expansion ratio1.15Middle gap must exceed the first gap by at least this ratio
Min contraction ratio1.15Middle gap must exceed the last gap by at least this ratio
Show outlinetrueDraw the four-point diamond outline
AlertstrueAlert once when a new diamond completes

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Pivot Points · Dashboards & Scanners · Buy/Sell Arrows · Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria