Join today
Strategies / Mean reversion / Fractal Dimension EMA Reversion

Fractal Dimension EMA Reversion

A bar that opens above the prior close but then closes under the 40 period EMA triggers a buy, as long as the 30 bar fractal dimension index is below 1.5. The mirror setup sells short. Every trade is closed exactly 4 bars later or at a 60 point stop.

Mean reversionLong & shortSwingGBP/USD4 hours
n/aProfit factor
1,375Net profit USD
47.35%Win rate
906Trades
-1,363Max drawdown
1.52Avg trade

Best run of 2. GBP/USD, 4 hours, spread 1.5, from run sweeps:2026-09-21-GBPUSD-4h-opt.tsv:4.

Entry rules, long

  1. The bar opens above the previous close
  2. Members only
  3. The 30-bar fractal dimension index is below 1.5
  4. No long is open
  5. Filled at the next bar's open

Entry rules, short

  1. The bar opens below the previous close
  2. Members only
  3. The 30-bar fractal dimension index is below 1.5
  4. No short is open
  5. Filled at the next bar's open

Exit rules

  1. Members only
  2. Stop loss of 60 points

Test conditions

PeriodUp to 2026-09-21
InstrumentGBP/USD, 4 hours
Spread1.5 points
Contracts1
Starting capital1,000,000
CostsSpread only. Commissions and overnight financing are not included.
BarsUp to 200,000 bars, fewer where the instrument has less history
Last tested2026-09-21

Parameters

positionSize
Contracts per trade
1
emaPeriod
EMA length for the signal
40
fdiPeriod
Fractal dimension lookback
30
fdiThreshold
Trade only when the fractal dimension is below this
1.5
maxBarsInTrade
Close the trade exactly this many bars after entry
4
stopLossPoints
Protective stop in points
60

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
GBP/USDBest run4 hoursn/a 90647.351,375 USD-1,363
DAX 40Dailyn/a 35831.562,147 EUR-1,902

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-2K-1K1K3KDAX 40 · DailyGBP/USD · 4 hours

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// Fractal Dimension EMA Reversion
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Mean reversion
// Direction: Long & short
// Timeframe tested: 4 hours
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false

// --- Parameters ---
positionSize = 1          // contracts per trade
emaPeriod = 40            // EMA length for the signal
fdiPeriod = 30            // fractal dimension lookback
fdiThreshold = 1.5        // trade only when the fractal dimension is below this
maxBarsInTrade = 4        // close the trade exactly this many bars after entry
stopLossPoints = 60       // protective stop in points

// --- Indicators ---
emaValue = ExponentialAverage[emaPeriod](close)

// Fractal dimension index: near 1 = trending, near 2 = choppy.
// Undefined until enough history, so the filter blocks early trades.
ONCE fdiValue = undefined

IF BarIndex >= fdiPeriod - 1 THEN
  pathLength = 0
  prevScaled = 0
  fdiValue = 0
  fdiHigh = Highest[fdiPeriod](close)
  fdiLow = Lowest[fdiPeriod](close)

  FOR i = 1 TO fdiPeriod - 1 DO
    IF (fdiHigh - fdiLow) > 0 THEN
      scaledPrice = (CustomClose[i] - fdiLow) / (fdiHigh - fdiLow)
      IF i > 1 THEN
        pathLength = pathLength + SQRT(SQUARE(scaledPrice - prevScaled) + (1 / SQUARE(fdiPeriod)))
      ENDIF
      prevScaled = scaledPrice
    ENDIF
  NEXT

  IF pathLength > 0 THEN
    fdiValue = 1 + (LOG(pathLength) + LOG(2)) / LOG(2 * fdiPeriod)
  ELSE
    fdiValue = 0
  ENDIF
ENDIF

barsInTrade = BarIndex - TradeIndex

26 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • Profit factor was not recorded. The results come from parameter sweeps only.
  • The edge is very thin. On GBP/USD 4 hours the average trade was 1.52 USD and the drawdown of 1,363.2 USD almost equals the 1,374.7 USD net profit.
  • DAX 40 Daily won only 31.56% of its trades and drew down 1,902.2 EUR for a 2,147.3 EUR gain.
  • Only two markets were tested, so there is little evidence beyond GBP/USD and DAX 40.

Indicators used

EMAFractal Dimension Index

How to load it

  1. Copy the code with the copy button above the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Questions

About this strategy

Can it be run in ProOrder?

Yes. Entries fill at the next bar open and exits are a 4 bar time stop plus a 60 point stop, all coded.

How did the tests go?

GBP/USD 4 hours made 1,374.7 USD over 906 trades with a 47.35% win rate. DAX 40 Daily made 2,147.3 EUR over 358 trades.

What risk comes with 1 contract?

The worst drawdown on GBP/USD 4 hours was 1,363.2 USD at 1 contract, close to the full profit of the test.

Why the 4 hour chart?

A 4 bar hold on 4 hour bars keeps trades to under a day of market time, which suits a short reversion idea on a currency pair.

Related

Strategies like this one

Monday Dip Buy

Uses the same indicator.

n/a PF · 146 trades

SuperTrend CCI

Best run on the same market, GBP/USD.

1.72 PF · 561 trades

ATR Band

Also a mean reversion strategy.

10.31 PF · 53 trades

Want to see which reversion ideas make it into live trading? Join the ProRealAlgos waitlist.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs