LearnForexHub
EA

EA: Volume Spike Breakout Expert Advisor

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

Indicators draw and alert; an Expert Advisor goes further and actually submits orders for you. This free EA trades an N-bar price breakout, the same kind of setup covered in the Volumes lesson, but it refuses to act on the breakout alone: it only enters when the breakout bar's own tick volume is spiking well above its recent average, using volume as a direct participation check rather than a cumulative indicator like OBV or A/D. Stop Loss, Take Profit, and position size are then all calculated automatically from ATR and account risk, the same chassis used by every EA on this site.

How the Strategy Works

The raw entry signal is the same kind of N-bar breakout used elsewhere on this site: has the just-closed bar's Close finished above the highest High of the prior BreakoutPeriod bars (default 20), or below the lowest Low of the same window? Because the band is built only from bars before the one being tested, a breakout here always means price has genuinely moved beyond the recent lookback window, not merely that the current bar happens to be part of its own new extreme.

Where this EA differs from a plain breakout system is the second condition it demands before trusting that signal: the just-closed bar's tick volume has to exceed VolumeSpikeMultiplier × its own VolumeAveragePeriod-bar average volume (default multiplier 2.0, meaning volume needs to be at least double its recent average). This is a deliberately simpler check than the cumulative-total confirmation used by the A/D Trend Confirmation EA or an OBV-based system — it doesn't ask whether a running total has built up over many bars, it asks a single, direct question about the exact bar the breakout happened on: was there an unusual burst of activity right here, right now? A breakout bar with ordinary, unremarkable volume is treated as unconfirmed and ignored entirely, regardless of how clean the price break looks.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUYTick VolumeVolume spike
Entry conditions: BUY when price closes above the N-bar high at the same time volume spikes above its recent average — the mirrored breakdown-plus-spike triggers SELL — SL and TP are placed automatically from ATR

Stop Loss and Take Profit are sized from ATR rather than from the breakout band itself — 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), giving every trade this EA opens the same fixed reward-to-risk shape regardless of pair or timeframe.

Sizing uses the worked example from Risk Management Basics directly — RiskPercent (default 1.0%) of balance over the stop distance — so the money at risk stays near-constant as the ATR stop expands and contracts. Lot Sizes Explained covers how that figure is then snapped to the broker's minimum, maximum, and lot step before the order goes out. UseFixedLot remains available for anyone preferring a constant lot size independent of the risk calculation.

Entry Conditions

  • BUY — the just-closed bar's Close is above the highest High of the BreakoutPeriod bars before it, and that same bar's volume is greater than VolumeSpikeMultiplier × the VolumeAveragePeriod-bar average volume.
  • SELL — the just-closed bar's Close is below the lowest Low of the BreakoutPeriod bars before it, and that same bar's volume clears the same spike threshold — the mirrored setup.

If price breaks the band but the breakout bar's volume doesn't clear the spike threshold, the EA does nothing at all — the price move is logged internally as "seen" but never acted on. The same three guardrails used across this site's EA collection apply here: signals are evaluated only when a new bar opens (tracked by its open time), so one bar can't fire twice; only one position may be open at once, verified by counting trades under this EA's symbol and magic number; and entries are skipped whenever the live spread exceeds MaxSpreadPoints (default 30). Every order is tagged with MagicNumber (default 20260808), so the EA's position-counting logic never touches a trade opened manually or placed by a different EA running on the same account.

Parameters

  • BreakoutPeriod (default 20) — the lookback window the highest-high/lowest-low entry band is built from. A shorter period triggers more, smaller breakouts; a longer period requires a larger move before entering.
  • VolumeAveragePeriod (default 20) — the lookback window, in bars, for the average volume the breakout bar's volume is compared against.
  • VolumeSpikeMultiplier (default 2.0) — how many times the average volume the breakout bar must exceed to confirm the entry. Raising it (e.g. 3.0) demands a more extreme volume burst and yields fewer, higher-conviction trades; lowering it (e.g. 1.5) lets more breakouts through, including some on only moderately elevated volume.

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 20260808.

Why Volume, Not Just a Trend Filter

Every breakout EA on this site faces the same core problem: a new N-bar high or low only tells you price reached a new extreme, not whether real participation was behind it. The Donchian Breakout EA trades every qualifying breakout unconditionally, which means it also trades every thin, unconvincing one — a large share of what makes breakout systems lose money is exactly this pattern, a false breakout that prints on light activity and snaps straight back into the range once the imbalance clears.

This EA's answer is the most direct one available: check the volume on the breakout bar itself, right now, rather than inferring participation indirectly from a trend-strength reading like ADX or a cumulative volume total like OBV or A/D. A tick-volume spike at the exact moment price clears the band is a strong, immediate signal that something changed in how the market is trading this pair — more orders, more urgency, more disagreement between buyers and sellers being resolved right at that level — which is a meaningfully different kind of evidence than a slower-building cumulative total climbing over many bars. The trade-off is that this check is also noisier bar to bar than a cumulative confirmation: a single-bar volume spike can be a one-off event (a large order, a news headline, a stop cascade) that doesn't reflect sustained conviction the way a multi-bar OBV or A/D new high does. Because of that, treat a volume-spike-confirmed breakout as a filter that removes a specific category of bad trade (breakouts on dead, empty markets) rather than a filter that guarantees the move continues — pairing it with a broader trend read (see Trend vs Range) is worth doing before assuming a confirmed breakout will hold.

A Word of Caution

Before real money, run it on a demo account across several pairs and market phases; good historical or demo results never guarantee the future. This EA can and will lose on individual trades: a volume spike confirms only that activity was unusually high on the breakout bar, not that the move that follows will continue, and a spike can just as easily accompany a stop run or a news-driven overreaction that reverses shortly after as it can a genuine, sustained breakout. Remember too that "volume" on a retail forex feed is tick volume, not true traded volume, so this is a proxy for participation rather than an exact measurement of it — see the Volumes lesson for that caveat in full. What you download below is source, not a compiled black box — go through it and understand every parameter before attaching it to a real account. As with every lesson on this site, this is educational material, not advice tailored to your situation.

Download volume-spike-breakout-ea.mq4

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

Download File

Download volume-spike-breakout-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 volume-spike-breakout-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 volume-spike-breakout-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.