Loading…

Contraction Sequence System

A single narrow bar (an NR4/NR7-style pattern) is a well-known coiling signal, but a genuine sequence of several consecutive bars each tighter than the last is a stronger version of the same idea - real, multi-bar compression rather than one quiet session. This EA looks for exactly that: a run of consecutive bars whose true range strictly shrinks bar over bar, confirmed by walking the sequence from oldest to newest. The bar immediately following the sequence is the trigger. It must do two things at once: its own true range must expand back out past the tightest bar in the sequence (confirming this is the release, not another quiet bar), and its close must break the high or low of that tightest bar. Only then is a trade taken, in the direction of the break. The take profit is not an arbitrary multiple of the entry's own risk - it is sized from the widest true range actually seen in a separate lookback window before the sequence, a genuine "how far does this instrument typically move once it releases" figure for the symbol and timeframe in use, projected from the breakout price. The stop sits just beyond the far side of the contracted range, where the entire premise of the trade is proven wrong. Notes and limitations - This project reimplements the catalogue's standard helper functions (retryable-error classification, pip/lot normalisation, position lookup by magic number) locally rather than including another project's file, per house style - each submission is self-contained. - Named and designed around daily-bar contraction sequences, but the code operates on whatever timeframe the chart is set to; on very low timeframes a "true range" sequence is much noisier and the pattern will fire far more often with lower reliability. - True range uses the standard high/low plus prior-close gap formula; on symbols with frequent weekend or session gaps this can inflate the measured range on the first bar after a gap. - The target is a fixed take profit sized from historical typical ranges, not trailed; a move that stalls before reaching it will not be captured early. - Signals are evaluated once per closed bar, not on every tick. - One position at a time, tracked by InpMagicNumber. - Requires AutoTrading enabled (IsTradeAllowed()); if trading is disabled the EA logs it and skips the entry.

Expert advisor · MT4 · v1.0 · Free

About Contraction Sequence System

Contraction Sequence System is an expert advisor (trading robot) for MetaTrader 4. It can size trades from your balance and risk percent and trades breakouts. It has 11 settings, such as Contraction bars, Expansion lookback and Target range multiple. MQL source code included.

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

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Contraction bars4Consecutive bars required to confirm a contraction sequence
Expansion lookback20Bars scanned for a typical expansion range to size the target
Target range multiple1.0Target distance = this multiple of the typical expansion range
Stop buffer pips10Buffer added beyond the contracted range for the stop
Use risk sizingfalseSize by percent risk 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 fallback
Magic number20260604Magic 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 4 open File → Open Data Folder, then go to MQL4 → Experts.
  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 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: Breakout · Buy/Sell Arrows · Trading Sessions · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria