Gap Class Conditional System
Treating every weekend gap as one undifferentiated signal is the common mistake this EA avoids. On the Monday daily bar it measures the gap between Monday's open and Friday's close in units of an InpAtrPeriod-bar ATR, and compares its direction against Friday's own intraday move (Friday's close vs Friday's open), which sorts the gap into one of three classes. A COMMON gap (below InpCommonAtrMax ATRs) is small enough that it is statistically the most likely to simply fill, so it is traded as a fade back toward Friday's close. A BREAKAWAY gap (at or above InpBreakawayAtrMin ATRs, in the SAME direction Friday was already moving) is read as genuine continuation and traded WITH the gap. An EXHAUSTION gap (the same large size, but AGAINST Friday's own direction) is read as a stop-run or overreaction rather than the start of a new leg, and is faded the same way as a COMMON gap, for a different underlying reason. Each class can be independently enabled or disabled, so the published defaults are a reasonable starting point, not a claim that all three classes carry the same edge on every instrument - a user who tracks actual results per class can narrow the EA to only the classes that perform on their symbol. Notes and limitations - Classification and trading both happen once per calendar week, at the configured Monday server hour - if the terminal is offline at that exact hour on a given week, that week's gap is missed entirely, it is not caught up on the next tick. - A gap between the COMMON and BREAKAWAY/EXHAUSTION thresholds (i.e. not clearly small or clearly large) is conservatively treated as COMMON - this is a deliberate default, not a bug, but means the BREAKAWAY/EXHAUSTION thresholds effectively define the boundary of "large enough to trust a directional read." - Server time, not broker-local trading-week time, is what "Monday" and the evaluation hour are measured against - check your broker's server time offset before relying on the exact hour chosen. - Lot sizing uses MODE_TICKVALUE/MODE_TICKSIZE, not a hardcoded contract size. - Only one position at a time; a maximum of one trade per week by construction.
Expert advisor · MT5 · v1.0 · Free
About Gap Class Conditional System
Gap Class Conditional System is an expert advisor (trading robot) for MetaTrader 5. It can size trades from your balance and risk percent. It has 16 settings, such as Atr period, Common atr max and Breakaway atr min. MQL source code included.
Files in the download: GapClassConditionalSystem.ex5, GapClassConditionalSystem.mq5, GapClassConditionalSystem.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Atr period | 14 | Bars used for the daily ATR that sizes the gap classification |
| Common atr max | 0.5 | Gap below this many ATRs classifies as COMMON |
| Breakaway atr min | 1.0 | Gap at or above this many ATRs, WITH Friday's direction, classifies as BREAKAWAY |
| Trade common | true | Trade the COMMON class (fade toward Friday's close) |
| Trade breakaway | true | Trade the BREAKAWAY class (continuation with the gap) |
| Trade exhaustion | true | Trade the EXHAUSTION class (fade, large counter-trend gap) |
| Entry hour server | 0 | Server hour on Monday to evaluate and act on the gap (0-23) |
| Use risk sizing | true | Size by percent risk to the stop instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a sizing fallback |
| Stop atr multiple | 0.5 | Stop distance as a multiple of the daily ATR |
| Reward risk ratio | 1.0 | Take-profit distance as a multiple of the stop distance |
| Magic number | 43751 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: ATR · Buy/Sell Arrows · Trading Sessions · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code