Gap Type Classifier
A gap's size alone says nothing about what it means - a three-pip gap on a quiet Monday open and a three-pip gap after a two-week trend both look identical if you only measure the jump. The classic gap taxonomy separates them by context instead: a Breakaway gap leaves a prior base on rising volume and marks the start of a move; a Runaway gap appears mid-trend on average-or-better volume and confirms the move is continuing; an Exhaustion gap appears late in an already-stretched move on climactic volume and often marks its end; a Common gap has none of that supporting context and usually fills soon after. This indicator rebuilds that context from data already on the chart. Trend position comes from price relative to a simple moving average read at the bar BEFORE the gap, never the gap bar itself, so the gap's own move can never contaminate the trend read that is supposed to explain it. Volume context is the gap bar's own tick volume (forex has no real traded volume, so tick volume is the standard proxy) against its own trailing average, excluding itself from that average. Extension context is how far price has already travelled through its recent swing range, in the trend direction, measured at the bar before the gap - this is what tells Runaway apart from Exhaustion: the same elevated volume on an already-stretched move reads as Exhaustion, on a move still early in its range it reads as Runaway. Every classified gap is drawn as a rectangle over its price zone, coloured by type, and left open on the right edge until price later trades back through the full zone - at which point the box is marked filled with a dotted grey outline and a "(filled)" label, so a glance at the chart shows which gaps are still live support/resistance and which have already been absorbed. Notes and limitations - Classification is a rules-based approximation of a subjective classical chart-reading concept, not a certainty - the same gap can reasonably be read differently by different traders. Treat the label as a starting hypothesis, not a signal to act on alone. - Early in a symbol's visible history (fewer bars than InpTrendMaPeriod + InpExtensionLookback before a gap) there is not enough context to score trend/extension/volume properly, so the gap defaults to Common rather than guessing. - A gap is detected once, at the bar whose open first jumped away from the prior close; a box's right edge then extends with the current bar until it is filled, at which point it locks to the fill bar's time. - Fill detection requires price to trade through the ENTIRE gap zone (high >= top and low <= bottom on the same bar or any later one) - a partial retrace into the zone does not count as filled. - Purely a visual/analytical overlay: no alerts, no trade signals, no repainting of already-classified gaps (a gap's type is fixed at detection and never re-scored as later bars arrive).
Indicator · MT4 · v1.0 · Free
About Gap Type Classifier
Gap Type Classifier is an indicator for MetaTrader 4 based on Moving Average. It has 15 settings, such as Min gap pips, Trend ma period and Extension lookback. MQL source code included.
Files in the download: GapTypeClassifier.ex4, GapTypeClassifier.mq4, GapTypeClassifier.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Min gap pips | 3.0 | Smallest gap (in pips) worth classifying |
| Trend ma period | 50 | MA period used to judge trend direction/position |
| Extension lookback | 30 | Bars searched for the recent swing high/low (extension test) |
| Extension percent | 70.0 | Move must have covered this % of the lookback range to count as "extended" |
| Volume avg period | 20 | Bars averaged for the normal tick-volume baseline |
| Breakaway vol ratio | 1.30 | Gap-bar volume / average must exceed this for Breakaway |
| Exhaustion vol ratio | 1.80 | Gap-bar volume / average must exceed this for Exhaustion |
| Max tracked gaps | 200 | Most recent gaps kept tracked for fill detection |
| Max history bars | 3000 | Bars scanned back from the current bar on first run |
| Show labels | true | Draw a text tag naming each gap's type |
| Common color | clrSilver | Box colour: Common |
| Breakaway color | clrDodgerBlue | Box colour: Breakaway |
| Runaway color | clrLimeGreen | Box colour: Runaway |
| Exhaustion color | clrOrangeRed | Box colour: Exhaustion |
| Filled color | clrGray | Box outline colour once the gap is filled |
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: Volume · Trend · Moving Average · MT4 Indicator · MQL4 Source Code