Loading…

Double Top Completion Rate Study

Chart pattern write-ups describe the double top's measured-move target - project the peak-to-neckline distance past the neckline - as if it were reliable, almost never with an attached completion rate. This script measures it directly. It finds swing highs and swing lows with a fractal window, then looks for two CONSECUTIVE same-side swings of similar height (within a configurable tolerance) with a genuine dip or rally between them serving as the neckline. From there it searches forward for the first confirmed close-through break of the neckline by a threshold - a pattern whose price closes back above its own peaks (for a double top) before ever breaking the neckline is treated as invalidated, not counted. Once the break is confirmed, the measured-move target is projected - the peak-to-neckline distance mirrored past the neckline - and the script searches forward from the break for one of three outcomes within a fixed window: the target was reached, price failed back through the neckline without reaching it, or neither happened before the window ran out. Double tops and double bottoms are reported separately, since the two are not mirror images in practice - trending markets do not treat tops and bottoms symmetrically. Notes and limitations - Only patterns whose neckline actually breaks within InpMaxBreakSearchBars are counted; a pair of similar peaks that never breaks its neckline never produces an event, which is deliberate - an unconfirmed pattern has no defined outcome to measure. - The neckline is read as the single lowest low (for a top) or highest high (for a bottom) between the two peaks/troughs - not a separately detected swing point - since the neckline itself does not need to be a confirmed fractal, only the true extreme of the intervening move. - The target-hit check uses the bar's low/high extreme, but the failure check uses the bar's close - a target can be hit by a wick on the same bar a close would have called a failure; the script always evaluates the target condition first, so a bar satisfying both is scored a hit. - This is a descriptive study, not a trading signal. It ignores spread and slippage, and does not account for pattern quality beyond the measurable geometry - volume, for instance, plays no role here.

Script · MT5 · v1.0 · Free

About Double Top Completion Rate Study

Double Top Completion Rate Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Symbol, Timeframe and Max bars. MQL source code included.

Files in the download: DoubleTopCompletionStudy.ex5, DoubleTopCompletionStudy.mq5, DoubleTopCompletionStudy.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to study, blank = this chart's symbol
TimeframePERIOD_H1Timeframe to study
Max bars3000Most recent bars to include
Swing window5Bars each side required to confirm a swing high/low
Peak tolerance pips10.0Max price difference between the two peaks/troughs to call it a "double"
Break threshold pips5.0Close-through distance past the neckline required to confirm the breakout
Max break search bars200Furthest past the second peak/trough searched for the neckline break
Max target bars200Furthest past the confirmed break searched for the measured-move target
Save csvtrueWrite every detected pattern's outcome to a CSV file

How to install

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

Download the PDF guide

Tags: Fractals · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria