LearnForexHub
EA

EA: Ultimate Oscillator Reversal Expert Advisor

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

A plotted line or an alert is where an indicator stops — an EA continues on and places the trade. This free EA trades the Ultimate Oscillator leaving its extreme zones: when the oscillator climbs back above 30 after a stretch of oversold readings, it opens a BUY, and when it drops back below 70 after being overbought, it opens a SELL — with Stop Loss, Take Profit, and position size all calculated automatically from ATR and account risk.

How the Strategy Works

The entry signal is built on the same three-period blend covered in the Ultimate Oscillator lesson. For every bar the EA computes Buying Pressure (Close − min(Low, previous Close)) and True Range (max(High, previous Close) − min(Low, previous Close)), sums each separately over 7, 14, and 28 bars, divides to get three ratios, and blends them with a 4:2:1 weighting into a single 0-100 reading. Neither MetaTrader 4 nor MetaTrader 5 has a built-in Ultimate Oscillator function, so all of this is calculated inside the EA itself.

The trade trigger is deliberately the exit from an extreme zone rather than entry into it. When the oscillator is below 30, all three look-back windows agree that sellers have been holding the ground they took — that is not a moment to buy into. The EA waits for the reading to cross back above 30, which is the first bar on which the shortest and most heavily weighted window has actually turned. The overbought side works identically in reverse: nothing is sold while the reading sits above 70; the SELL fires on the cross back below it.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUY7030Ultimate Oscillator (7, 14, 28 — bounded 0–100)UO
Entry conditions: BUY when the Ultimate Oscillator crosses back above 30 — SELL when it crosses back below 70 — SL and TP are placed automatically from ATR

Both Stop Loss and Take Profit are sized from ATR rather than a fixed pip distance, so the stop always reflects how much the pair is actually moving right now. Stop Loss distance is ATRMultiplier × ATR (default multiplier 2.0, ATR calculated over ATRPeriod, default 14), and Take Profit is then set at RiskRewardRatio × Stop Loss distance (default 2.0) — every trade this EA opens carries the same fixed reward-to-risk proportion regardless of pair or timeframe.

ATR-based sizing matters more for a reversal strategy than for a trend strategy, because reversal entries happen precisely where volatility has usually just expanded. A fixed 30-pip stop that was comfortable during a quiet range is inside the noise of a single bar after a sharp sell-off — the trade would be stopped out by ordinary movement rather than by the idea being wrong. Position size follows the exact worked-example method from Risk Management Basics: RiskPercent (default 1.0%) of account balance divided by the Stop Loss distance, so the wider ATR stop automatically produces a smaller lot and the dollar risk stays constant. See Lot Sizes Explained for how that figure is normalized to the broker's minimum, maximum, and step lot constraints. UseFixedLot is available as an escape hatch for a constant lot size.

Entry Conditions

  • BUY — the Ultimate Oscillator was at or below OversoldLevel (default 30) on the previous bar and closed above it on the just-closed bar.
  • SELL — the oscillator was at or above OverboughtLevel (default 70) on the previous bar and closed below it on the just-closed bar — the mirrored condition.

Three safety mechanics govern every trade this EA can place, matching the standard used across every EA on this site: it evaluates entry conditions once per new bar only, tracked via the bar's open time, so a single qualifying bar can't trigger repeated entries within the same candle; it opens only one position at a time, checked by counting open trades filtered to this EA's own symbol and magic number before any new entry is considered; and it checks the current spread against MaxSpreadPoints (default 30) before sending an order, skipping the entry when the spread is too wide. Every order is tagged with MagicNumber (default 20260825), so the EA's position-counting logic never touches a trade opened manually or placed by a different EA on the same account.

Parameters

  • FastPeriod / MiddlePeriod / SlowPeriod (defaults 7 / 14 / 28) — the three look-back windows blended into the reading. The 4:2:1 weighting is fixed; what you control is how long each window is. Doubling all three produces a much slower oscillator suited to higher timeframes.
  • OversoldLevel (default 30) — the level a BUY triggers on when the oscillator crosses back above it. Lowering it toward 25 demands a deeper extreme and trades less often.
  • OverboughtLevel (default 70) — the mirror for SELL entries. Raising it toward 75 has the same selectivity effect.

The remaining parameters aren't specific to this strategy: they belong to the risk engine shared across the whole EA collection, explained in one place on the EA hub. This EA identifies its own trades with magic number 20260825.

Why the EA Waits for the Zone Exit

Every oscillator-based EA has to answer the same question: do you act while the reading is extreme, or when it stops being extreme? Acting inside the zone gets a better entry price on the trades that work and is catastrophic on the ones that don't, because "oversold" has no floor. A pair can sit under 30 for twenty consecutive bars during a genuine breakdown, and an EA that buys on the first oversold bar will have opened, been stopped out, and re-opened several times before the move is over. Requiring the cross back out costs some of the best entry price but guarantees that at least one bar of real upward pressure has printed before any money is committed.

This EA takes an additional deliberate stance: unlike this site's CMF Trend EA, it ships with no trend filter, so it trades both directions in every market condition. That is not an oversight — it's what makes it a clean reference implementation of the reversal idea, and it is also its main structural weakness. Traders who find it fights sustained trends too often have a straightforward remedy: run it on a higher timeframe where extremes are rarer, tighten OversoldLevel/OverboughtLevel to 25/75, or check the pair's market structure manually and only leave EnableTrading on when the pair is genuinely ranging rather than trending.

A Word of Caution

Trial it on demo first, over multiple pairs and differing conditions, before real funds are at stake — a strong backtest or demo run guarantees nothing going forward. This EA can and will lose on individual trades, and as a countertrend system with no trend filter, it will lose several in a row during any strong sustained move; that is the expected behaviour of the strategy, not a malfunction. The Ultimate Oscillator's three-period blend makes it slower to reach extremes than RSI or Stochastic, which means fewer signals but also later ones. Consider pairing it with a higher-timeframe bias check — see Trend vs Range — rather than running it unfiltered through every market condition. Both the MT4 and MT5 files below are source code: open and read them fully, and understand exactly what every parameter does, before attaching this EA to a live account. Nothing on this page is personalized investment advice; it is general education about how the tool works.

Download ultimate-oscillator-reversal-ea.mq4

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

Download File

Download ultimate-oscillator-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 ultimate-oscillator-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 ultimate-oscillator-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.