Loading…

Fractal Dimension Gated Trend System

An EMA crossover alone fires on plenty of moves that are really just noise walking two averages across each other - the crossover says the averages disagree, not that price is actually trending. This system adds a second, independent confirmation: the fractal dimension of the recent price path, computed with the same geometry as this catalogue's FractalAdaptiveMa indicator (John Ehlers' FRAMA) - split the lookback window into two halves plus one full-window pass, compare their price ranges, and derive a dimension between 1 (smooth, trending) and 2 (rough, effectively random). Reimplemented here as a direct per-bar snapshot rather than reused as a recursive moving average, since this system only needs the current dimension reading, not FRAMA's smoothed output line. An entry is only taken when the EMA cross agrees with the trend direction AND the measured dimension is at or below InpMaxDimension - i.e. price is behaving like a trend, not like noise that happened to cross two averages. An open position is closed early, independent of its stop or target, the moment dimension climbs back above InpExitDimension - a wider threshold than the entry gate, so ordinary noise around the entry level does not flap the position in and out on every bar. Position sizing is risk-based (InpRiskPercent of balance, sized off the symbol's own tick value and tick size), never a hardcoded contract size, which would mis-size metals, indices and JPY crosses. Exits are managed through a ticket-collect-first loop over this system's own magic number, so management never acts against a re-indexing order pool mid-loop. Notes and limitations The fractal dimension calculation needs 2 x InpFractalHalfWindow bars of clean high/low data; it will not evaluate before that much history exists. This is a whole-symbol trend filter, not a pattern detector - it says nothing about support/resistance, news events or session timing. Grid, martingale and averaging are NOT used anywhere in this system; every position is single, risk-sized and independently stopped. Only one position per magic/symbol is held at a time; a second entry signal while already in a position is ignored until the current one closes.

Expert advisor · MT4 · v1.0 · Free

About Fractal Dimension Gated Trend System

Fractal Dimension Gated Trend System is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average and ATR. It can size trades from your balance and risk percent. It has 13 settings, such as Magic, Fast ema period and Slow ema period. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Magic20261301Magic number for this system's own orders
Fast ema period12Fast EMA period
Slow ema period34Slow EMA period
Fractal half window8Half-window for the fractal dimension calc (full window = 2x this)
Max dimension1.45Entries allowed only while dimension <= this (near 1 = trending)
Exit dimension1.75Existing position closed early if dimension climbs above this (trend lost)
Atr period14ATR period for stop/target distance
Atr stop multiple2.0Stop distance as a multiple of ATR
Atr target multiple3.0Take-profit distance as a multiple of ATR
Risk percent1.0Risk % of balance per trade
Max slippage points5Slippage tolerance passed to OrderSend
Max retries5Attempts per order 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: Price Action · Moving Average · Fractals · Trend · Risk & Lot Size · ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria