LearnForexHub
EA

EA: RVI Signal Cross Expert Advisor

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

Where an indicator stops at plotting a line or sounding an alert, an Expert Advisor goes one step further and sends the trade itself. This free EA trades a single, transparent momentum strategy built on the Relative Vigor Index end to end: entry, Stop Loss, Take Profit, and position size, all calculated automatically the moment a qualifying signal appears.

How the Strategy Works

The entry signal is a main-line/signal-line crossover on RVI — the exact same shape of signal as a %K/%D cross on Stochastic, but built from a completely different calculation underneath. RVI's main line measures how convincingly each candle closes away from its open relative to that candle's own high-low range, smoothed over a lookback period (RVIPeriod, default 10); the signal line is a moving average of that main line. A BUY setup fires the moment the main line crosses from at-or-below the signal line to above it; a SELL setup is the exact mirror, the main line crossing from at-or-above down through the signal line. There's no zone requirement here — no waiting for an extreme reading the way an overbought/oversold-filtered EA would — every qualifying cross is treated as a valid signal, which keeps the logic simple but also means the trend-strength discussion further down matters more for an EA built this way.

Both lines oscillate around a zero centerline with no fixed upper or lower bound, unlike Stochastic's bounded 0-100 range. That has no bearing on whether a cross counts as a signal in this EA's code — a cross is a cross whether it happens above, at, or below zero — but it does affect how much conviction sits behind it, a distinction covered in the comparison section below.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUY0RVI / Signal (oscillates around zero)
Entry conditions: BUY when RVI crosses above its Signal line — SELL on the mirrored cross below — SL and TP are placed automatically from ATR

Both Stop Loss and Take Profit are sized from ATR rather than a fixed pip distance — a volatile pair or session gets a wider stop automatically, and a calm one gets a tighter stop, so the stop always reflects what the market is actually doing right now rather than an arbitrary number picked in advance. The Stop Loss distance is ATRMultiplier × ATR (default multiplier 2.0), placed beyond the entry on the side the trade could be wrong. Take Profit is then set at a multiple of that same Stop Loss distance — the RiskRewardRatio input, default 2.0 — so every trade this EA opens targets twice as much reward as it risks, regardless of which pair or session it fires on.

Position size is calculated from a RiskPercent input (default 1.0%) against your account balance and the Stop Loss distance — the exact worked-example method from Risk Management Basics: risk amount ÷ Stop Loss distance (converted through the symbol's tick value) = lot size. A wider ATR-based stop on a volatile day automatically produces a smaller lot, and a tighter stop on a calm day produces a larger one, so the dollar amount actually at risk stays roughly constant trade to trade. A UseFixedLot input is available as an escape hatch for traders who'd rather trade a constant lot size regardless of the calculated risk.

Entry Conditions

  • BUY — the RVI main line crosses from at-or-below its signal line to above it.
  • SELL — the RVI main line crosses from at-or-above its signal line to below it.

The EA only evaluates these conditions once per new bar (not on every tick), only opens one position at a time, and only manages positions tagged with its own magic number (MagicNumber, default 20260734) — so it won't interfere with trades you open manually on the same account, and it won't stack additional trades on top of an open one. A MaxSpreadPoints filter also blocks new entries when the current spread is too wide, since a signal that looks good on the chart can still be a bad trade if the price you'd actually get filled at has slipped too far from the quote.

Parameters

  • RVIPeriod (default 10) — the lookback window used to smooth the close-open/high-low ratio into RVI's main line. A shorter period reacts faster and produces more crosses; a longer period smooths further and lags more, the same trade-off as shortening or lengthening the %K period in a Stochastic-based EA.

Beyond these, the EA exposes the same risk-engine inputs as every other EA on the site — stop and target sizing, risk-based lots, the spread filter, and the on/off switch — covered in detail on the EAs page. It stamps each order with magic number 20260734.

  • UseFixedLot / FixedLotSize — switches from risk-based sizing to a constant lot size, for traders who prefer a fixed position size regardless of stop distance.

RVI Cross vs Stochastic Cross: Same Signal Shape, Different Meaning

This EA and the site's Stochastic crossover EA look almost identical from the outside — both watch two oscillating lines and act the instant the fast one crosses the slow one — and that resemblance is deliberate to read, but the two crosses mean genuinely different things under the hood. Stochastic's %K asks where the current close sits within a recent high-low range; a %K/%D cross is a statement about price's position relative to its own recent history. RVI's main line asks how convincingly the current candle closed away from its own open relative to its own range; an RVI cross is a statement about conviction within the candles themselves, independent of where those candles sit in any longer lookback window.

That difference shows up most clearly in trending markets. Stochastic can pin near an extreme for an entire strong trend, which is why the Stochastic EA on this site only trades crosses that happen inside its Overbought/Oversold zones — filtering out the crosses that happen mid-range, where a reversal is least likely. RVI has no equivalent bounded range to pin against, so it has no equivalent zone filter, and every cross this EA sees is treated as tradable regardless of how far price has already run. That makes this EA's signal count higher in a persistent trend than the zone-filtered Stochastic EA's, but it also means more of those signals are counter-trend noise — a strong uptrend can still produce a run of small pullback candles that dip RVI's main line back under its signal line without the uptrend actually ending, and this EA will act on that dip exactly as readily as it acts on a genuine reversal. Neither design is strictly better; they're different trade-offs between simplicity and selectivity, and it's worth reading both lessons before deciding which cross-based approach fits a given pair's typical behavior.

A Word of Caution

Put it through a demo account across quiet and volatile markets before risking capital; what it did in the past, in a tester or live, says nothing certain about what it will do next. No trading system wins every position; expect this EA to lose on individual trades as a matter of course. Main/signal-cross EAs like this one are especially prone to whipsaw in choppy, sideways markets: when price has no real direction, the two lines drift close together and cross back and forth repeatedly with no meaningful move behind any single cross, generating a steady drip of small losing trades with nothing in the code to sit those stretches out. This EA has no trend filter built in, so consider pairing it with a read of trend vs range before enabling it on a pair that's clearly rangebound, or layering in your own trend-direction filter (a higher-timeframe moving average, for instance) before it takes a signal. Since both versions are open source files, read the code yourself — every parameter should make sense to you before it ever touches a live chart. All of this is educational material; none of it is advice about what you personally should trade.

Download rvi-signal-cross-ea.mq4

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

Download File

Download rvi-signal-cross-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 rvi-signal-cross-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 rvi-signal-cross-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.