Loading…

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

SettingDefaultWhat it does
Atr period14Bars used for the daily ATR that sizes the gap classification
Common atr max0.5Gap below this many ATRs classifies as COMMON
Breakaway atr min1.0Gap at or above this many ATRs, WITH Friday's direction, classifies as BREAKAWAY
Trade commontrueTrade the COMMON class (fade toward Friday's close)
Trade breakawaytrueTrade the BREAKAWAY class (continuation with the gap)
Trade exhaustiontrueTrade the EXHAUSTION class (fade, large counter-trend gap)
Entry hour server0Server hour on Monday to evaluate and act on the gap (0-23)
Use risk sizingtrueSize by percent risk to the stop instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a sizing fallback
Stop atr multiple0.5Stop distance as a multiple of the daily ATR
Reward risk ratio1.0Take-profit distance as a multiple of the stop distance
Magic number43751Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

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 → Experts.
  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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: ATR · Buy/Sell Arrows · Trading Sessions · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria