An Expert Advisor (EA) is different from every other download on this site — an indicator only plots or alerts, while an EA actually sends orders on your behalf. This free EA trades a single, transparent reversal strategy built on the Stochastic Oscillator 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 %K/%D crossover on the Stochastic Oscillator, but not just any crossover — it only counts when it happens inside one of the extreme zones. A BUY setup requires %K to cross above %D while both lines are still below the Oversold level (default 20); a SELL setup requires %K to cross below %D while both lines are still above the Overbought level (default 80). This is the exact distinction the site's Stochastic lesson makes when it says "the crossover matters as much as the zone" — a %K/%D cross that happens in the middle of the range, say around a reading of 50, reflects nothing more than normal short-term noise, because there's no extreme reading behind it to suggest the move is exhausted. A crossover that happens down at 15 or up at 85, by contrast, is happening exactly where the underlying idea behind stochastic says a turn is more likely: price has been pressing hard into one edge of its recent range, and the crossover is the first sign that pressure is fading. Filtering every signal by zone this way is what keeps the EA from firing on the dozens of minor %K/%D wiggles that happen in the middle of the chart on every timeframe.
Stop Loss, Take Profit, and Position Size
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 = 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 — %K crosses above %D while both lines are below the Oversold level (default 20).
- SELL — %K crosses below %D while both lines are above the Overbought level (default 80).
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 20260721) — 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
- KPeriod / DPeriod / Slowing (default 5 / 3 / 3) — the classic "fast stochastic" configuration: a short lookback period with light smoothing, which makes %K and %D react quickly and cross often.
- Overbought / Oversold (default 80 / 20) — the extreme-zone thresholds a crossover must sit inside to count as a valid signal.
- ATRPeriod (default 14) — the lookback period used to calculate ATR for the Stop Loss distance.
- ATRMultiplier (default 2.0) — Stop Loss distance = ATR × this multiplier.
- RiskRewardRatio (default 2.0) — Take Profit distance = Stop Loss distance × this ratio.
- RiskPercent (default 1.0) — percentage of account balance risked per trade, used to calculate lot size. Ignored if
UseFixedLotis enabled. - UseFixedLot / FixedLotSize — switches from risk-based sizing to a constant lot size, for traders who prefer a fixed position size regardless of stop distance.
- MaxSpreadPoints (default 30) — skips new entries while the spread is wider than this, to avoid opening trades at a bad price during illiquid conditions.
- EnableTrading — a master on/off switch, useful for pausing the EA without removing it from the chart.
- MagicNumber (default 20260721) — tags every order this EA places, so its position-counting logic never touches trades opened manually or by a different EA on the same account.
Stochastic vs RSI as the Basis for a Reversal EA
Stochastic and RSI both hunt for the same kind of trade — a reversal near an extreme — but they get there with different machinery, and that difference matters for how an automated version of each behaves. RSI measures the size of recent up-closes versus down-closes, which makes it comparatively smooth and slow to move; stochastic measures where the latest close sits inside its recent high-low range, which makes it faster and busier. The (5, 3, 3) fast-stochastic settings this EA uses by default push that further: it will generate noticeably more crossover signals over a given stretch of price action than an RSI-based EA would over the same period, because %K and %D genuinely do cross more often than RSI crosses its own signal line. The zone filter described above is what keeps that extra sensitivity from becoming pure noise — requiring the cross to happen inside 20 or 80 discards most of the low-conviction wiggles, leaving a smaller set of higher-conviction ones.
That speed cuts both ways depending on market conditions. In a genuinely ranging market, this EA does well: price oscillates between the edges of a range, stochastic reaches its extremes repeatedly and cleanly, and each oversold-buy or overbought-sell signal has a real mean-reversion move behind it. In a strong trend, the same speed becomes a liability — stochastic can pin near 80 for an extended stretch of a strong uptrend (or near 20 in a strong downtrend), and because %K and %D are both compressed near the same extreme, they will still cross back and forth against each other even while price keeps marching in the trend direction, generating counter-trend signals that lose repeatedly. This EA has no trend filter built in, so it's best matched to range-bound conditions or checked against the site's Trend vs Range guidance before enabling it on a pair that's clearly trending hard in one direction.
Installation and Setup
EAs install into a different folder than indicators — this is the step people miss most often.
- Download the file below for your platform.
- Open MetaTrader → click
File→Open Data Folder. - Place the file in
MQL4/Experts(MetaTrader 4) orMQL5/Experts(MetaTrader 5) — not the Indicators folder. - Restart MetaTrader, then drag the EA from the Navigator window onto a chart.
- Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA will not place any trades while this is off, even if it's attached to a chart.
- Review and adjust the input parameters in the EA's settings dialog before confirming.
A Word of Caution
Test on a demo account first, across different market conditions, before risking real money — past performance, in backtests or live, never guarantees future results. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades; the zone filter reduces how often it fires on low-conviction wiggles, it doesn't eliminate losing trades, and it has no protection against a strong trend pinning stochastic at an extreme for an extended stretch. Both files are source code — open and review them fully, and understand what every parameter does, before using it. This content is general education, not personalized investment advice.
Download the EA
How to Install — MetaTrader 4
- Download the
stochastic-crossover-ea.mq4file below. - Open MetaTrader 4 → click
File→Open Data Folder. - Place the file in the
MQL4/Expertsfolder. - Restart MetaTrader 4, then drag the EA from the Navigator window onto the chart.
How to Install — MetaTrader 5
- Download the
stochastic-crossover-ea.mq5file below. - Open MetaTrader 5 → click
File→Open Data Folder. - Place the file in the
MQL5/Expertsfolder. - Restart MetaTrader 5, then drag the EA from the Navigator window onto the chart.
Both files are source code — open and review the full code before using it, for your own safety.