LearnForexHub
EA

EA: DeMarker Reversal Expert Advisor

Written by , Founder & EditorLast updated How we write and review lessons

Unlike the indicators on this site, which only draw on the chart or fire alerts, an Expert Advisor places real orders for you. This free EA trades a single, transparent mean-reversion strategy built on DeMarker: it watches for DeMarker to turn back out of the 0.7/0.3 extreme, then opens a trade with an ATR-based Stop Loss, an RR-multiple Take Profit, and a risk-based position size — all calculated automatically, with no manual chart-watching required.

How the Strategy Works

DeMarker is built differently from most of the oscillators on this site, and that shows up immediately in its scale. RSI runs 0-100, Stochastic runs 0-100, CCI has no fixed ceiling at all — but DeMarker is normalized to a 0-to-1 range, comparing how much of a recent bar's range fell above the prior bar's high against how much fell below the prior bar's low. A reading near 1.0 means recent price action has been dominated by fresh highs; a reading near 0.0 means it's been dominated by fresh lows. The 0.7 and 0.3 lines this EA watches play exactly the role that 70/30 play on RSI, just expressed on a different number line — 0.7 is "overbought," 0.3 is "oversold," and everything in between is normal chop.

As with every reversal EA on this site, the meaningful moment isn't DeMarker reaching an extreme, it's DeMarker turning back through it. A BUY setup forms when DeMarker (default 14-period, DeMarkerPeriod) crosses back above Oversold (default 0.3) after having been at or below it on the previous completed bar — not the bar where DeMarker first dips under 0.3, but the bar where it climbs back above that line. A SELL setup mirrors this exactly: DeMarker crossing back below Overbought (default 0.7) after having been at or above it. Trading the touch itself, rather than the turn back out, is the classic beginner mistake with any extreme-reading oscillator — this EA is built to avoid it mechanically, since it only evaluates the cross-back condition and never fires on the bar that first enters the zone.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUY0.70.3DeMarker (0 to 1 scale)
Entry conditions: BUY when DeMarker crosses back above 0.3 out of the oversold extreme — SELL on the mirrored cross back below 0.7 — SL and TP are placed automatically from ATR

Every trade's Stop Loss is sized from ATR rather than a fixed pip distance: SL distance = ATR (14-period, ATRPeriod) × ATRMultiplier (default 2.0). A volatile pair or session gets a wider stop automatically; a quiet one gets a tighter stop — the stop always reflects what the market is actually doing right now, rather than an arbitrary fixed number that's too tight on some pairs and too loose on others. Take Profit is then set at RiskRewardRatio (default 2.0) times that same SL distance, so every trade opened by this EA carries a fixed, known risk-to-reward ratio regardless of which pair or timeframe it's running on.

Position size is calculated the same way it's taught in Risk Management Basics: RiskPercent (default 1.0%) of account balance, divided by the Stop Loss distance and converted through the symbol's tick value, gives a lot size where a losing trade costs roughly the same fraction of the account no matter how wide or narrow that particular ATR-based stop happens to be. The result is normalized to the broker's minimum lot, maximum lot, and lot step before being sent with the order. Traders who'd rather trade a constant lot size regardless of account balance or stop width can flip on UseFixedLot, which overrides the risk-based calculation with a flat FixedLotSize instead.

Entry Conditions

  • BUY — DeMarker crosses from at-or-below the Oversold level back above it (DeMarker was ≤ 0.3 on the previous completed bar, and > 0.3 on the current bar).
  • SELL — DeMarker crosses from at-or-above the Overbought level back below it (DeMarker was ≥ 0.7 on the previous completed bar, and < 0.7 on the current bar).

On top of the signal itself, several safety mechanics keep the EA well-behaved on a live account. It opens one position at a time — before considering a new entry, it counts existing positions filtered by symbol and magic number, and skips the signal entirely if one is already open. Every order it places is tagged with its own magic number (20260733), so it never touches trades opened manually or by a different EA sharing the same chart or account. It evaluates entry logic once per new bar only, tracking the timestamp of the last bar it processed rather than re-checking on every incoming tick, so a single cross-back can't fire the same trade multiple times before the bar closes. And before sending any order, it checks the current spread against MaxSpreadPoints and skips the entry entirely if the market is too illiquid at that moment — the same concern covered in Spread and Slippage.

Parameters

  • DeMarkerPeriod (default 14) — the lookback period for the DeMarker calculation. Shorter reacts faster and crosses the 0.7/0.3 lines more often; longer is smoother and more selective.
  • Oversold (default 0.3) — the lower DeMarker threshold; a BUY fires when DeMarker crosses back above this level after having been at or below it.
  • Overbought (default 0.7) — the upper DeMarker threshold; a SELL fires when DeMarker crosses back below this level after having been at or above it.

All other inputs configure the common risk engine described on the EAs overview — how stops and targets are sized, how the lot is calculated from RiskPercent, and which safety checks gate every order. Its orders are tagged with magic number 20260733.

Why DeMarker's 0.7/0.3 Instead of RSI's 70/30

The numbers look arbitrary until you notice they're actually the same idea on two different rulers. RSI expresses momentum on a 0-100 scale because it's built from average gains and losses over a period, so 70/30 sit at the natural three-quarters and one-quarter marks of that range. DeMarker is built from a different question entirely — of the total high-low range covered by recent bars, how much of it represents a fresh high versus a fresh low relative to the prior bar — and its math happens to normalize that ratio onto 0 to 1 rather than 0 to 100. Multiply DeMarker by 100 and 0.7/0.3 become 70/30 again; the EA's thresholds aren't a different concept from RSI's, they're the identical concept expressed in the indicator's native units.

What actually matters for this EA isn't the arithmetic conversion, it's that the two indicators don't always agree on when a market is extreme, because they measure different things. RSI cares about the size of gains versus losses across the whole lookback; DeMarker cares specifically about how far each bar's high and low pushed past the prior bar's high and low. A market that grinds up in small, steady increments can hold an elevated RSI for a long stretch while DeMarker cools off faster, because DeMarker is more sensitive to the immediate bar-to-bar extension than to the cumulative trend. That makes DeMarker crosses somewhat quicker and choppier around the 0.7/0.3 lines in ranging conditions, and it's the practical reason to treat this EA's settings — and the trend conditions it's deployed into — as worth tuning independently rather than assuming an RSI-tuned strategy will behave identically once the threshold numbers are swapped for DeMarker's.

A Word of Caution

Run it on a demo account first, through different market conditions, before real money is involved; past results, whether from backtests or live trading, guarantee nothing about the future. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades. Mean-reversion systems in general get hurt in strong trending markets, and this EA is no exception: because the signal fires on any cross back through 0.3 or 0.7, a strongly trending market can push DeMarker below 0.3, bounce it briefly back above the line to trigger a BUY, then keep trending straight through the stop — a classic "catch a falling knife" scenario where the reversal never actually arrives. Consider pairing it with a trend-strength filter of your own, such as ADX or a trend vs range check, before enabling it on a live account, and compare its behavior against a related zone-reversal EA like CCI Reversal to see how the same idea plays out on a different oscillator. Both downloads are plain source files — read them end to end and make sure you understand each input before trusting them with an order. What you've read here is education about a tool, not investment advice for your account.

Download demarker-reversal-ea.mq4

For MetaTrader 4 — this is source code (.mq4), open and review it fully before using it.

Download File

Download demarker-reversal-ea.mq5

For MetaTrader 5 — this is source code (.mq5), open and review it fully before using it.

Download File

How to install

An EA installs into the Experts folder, not Indicators — this is the step people miss most often.

MetaTrader 4

  1. Download demarker-reversal-ea.mq4 above.
  2. Open MetaTrader 4FileOpen Data Folder.
  3. Place the file in the MQL4/Experts folder.
  4. Restart MetaTrader 4, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

MetaTrader 5

  1. Download demarker-reversal-ea.mq5 above.
  2. Open MetaTrader 5FileOpen Data Folder.
  3. Place the file in the MQL5/Experts folder.
  4. Restart MetaTrader 5, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

Both files are source code. Open and read them in MetaEditor before running them on any account.