Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
The Pivot Engulfing Scalper is a pure price-action expert advisor (EA) for MetaTrader 5 that combines structural pivot levels with the engulfing candlestick pattern to trade short-term momentum breakouts. It uses no traditional indicators — there is no moving average, RSI, ATR, or Bollinger Band anywhere in its logic. Instead, every decision is derived directly from raw candle data: the highest high, lowest low, and closing price of a recent window of bars. An engulfing candle is a two-bar pattern where the most recent candle's body completely covers and reverses the prior candle's body, a signal many traders read as a sudden shift in momentum.
The strategy is designed for liquid, momentum-prone markets — major forex pairs such as EUR/USD and GBP/USD, or gold (XAU/USD) — on intraday timeframes like M5, M15, or M30. These are the conditions where price repeatedly tests, breaks, and sometimes falsely breaks key structural levels. The EA is built around a single thesis: when a strong engulfing candle closes through a recent swing high or low, it may indicate that real momentum has shifted and that stop orders beyond the level are cascading.
As a learning tool, the Pivot Engulfing Scalper is well suited to traders who want to study breakout logic, candlestick structure, and hedge-based trade management in one self-contained system. It is best understood as a strategy analysis exercise — a way to see how pivots, patterns, breakouts, and a managed reversal hedge can be combined in code — rather than as a shortcut to results. Beginners should treat it as a study piece and always test on a demo account first.
How It Works
The strategy recomputes its key levels on every newly closed bar and only opens a fresh trade when the account is completely flat. Here is how the logic flows in plain English:
- Building the pivots: Over the
PivotLookbackclosed bars that precede the signal candle, the EA records the highest high (H), the lowest low (L), and the most recent close (C). It then calculates the classic pivot point PP = (H + L + C) / 3, the upside target R1 = 2·PP − L, and the downside target S1 = 2·PP − H. The pivot range (H − L) is used to size every buffer, so all distances scale automatically to any symbol or timeframe without hard-coded pip values.
- Long entry — bullish engulfing breakout: The strategy signals a buy when the just-closed candle is a bullish engulfing (an up candle whose body fully engulfs a prior down candle and is the larger of the two), and that candle opens at or below the prior swing high H but closes above it — a genuine break of structure — and price has not over-extended past H (controlled by
MaxExtendFrac). The take-profit is set to R1, the next pivot projection upward.
- Short entry — bearish engulfing breakout: The mirror-image rule. The strategy signals a sell when a bearish engulfing candle opens at or above the prior swing low L and closes below it, while remaining close enough to the level to count as a fresh scalp. The take-profit is set to S1.
- The hedge mechanic (the signature feature): A classic breakout trader's worst enemy is the false break — price pokes past a level, traps the breakout crowd, then snaps back. Rather than simply absorbing that loss, this EA responds. While the base leg is open, if price travels back through the broken level by
FailFracof a range, the break is treated as proven false and the strategy opens an opposite market leg. It now holds both directions — a locked hedge that aims to ride the reversal back toward the central pivot PP and offset the trapped base position.
- Stop-loss logic: The base trade's stop sits a structural pad (
StopFrac) beyond the hedge trigger, so the hedge always engages first. The hedge leg's own stop sits just past the broken level plus aReclaimFracpad — meaning the hedge is invalidated only if price reclaims the broken level and the original breakout resumes.
- Basket exit (the dominant exit): Whenever any exposure is held, the EA monitors net floating profit and loss across all its legs. If net floating P/L reaches
BasketTpMoney, it closes everything and banks the result. If net floating loss reachesBasketSlMoney, it flattens everything as a hard safety ceiling — protection against the failure mode where a strong one-way trend keeps running after the hedge locks.
- Spread filter: New entries are skipped while the spread exceeds
MaxSpreadPoints, helping avoid trades during illiquid or news-driven conditions.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 20 | 5 | 150 | Number of closed bars (before the signal candle) whose high/low/close define the pivot levels. |
| MaxExtendFrac | 0.35 | 0.05 | 2.00 | How far beyond the broken level the candle may close and still count as a fresh scalp (fraction of range). |
| FailFrac | 0.25 | 0.05 | 1.50 | Retrace back through the broken level, as a fraction of range, that proves the break false and triggers the hedge. |
| StopFrac | 0.35 | 0.05 | 2.00 | Extra base-stop pad placed beyond the hedge trigger (fraction of the pivot range). |
| RewardFrac | 0.60 | 0.10 | 4.00 | Minimum reward distance for the base and hedge take-profit (fraction of range). |
| ReclaimFrac | 0.30 | 0.05 | 1.50 | Hedge invalidation pad — if price reclaims the broken level by this much, the hedge is treated as wrong. |
| BasketTpMoney | 25.0 | 5.0 | 2000.0 | Net floating profit (account currency) at which the whole basket is closed. |
| BasketSlMoney | 300.0 | 50.0 | 100000.0 | Net floating loss (account currency) at which the whole basket is flattened. |
| MaxSpreadPoints | 50 | 0 | 500 | Skip new entries while spread (points) exceeds this value (0 = filter off). |
| Lots | 0.10 | 0.01 | 1.00 | Trade volume per leg, snapped to the symbol's volume step. |
| Magic | 7733 | 0 | 9,999,999 | Magic number used to identify and manage this EA's own positions. |

Recommended Chart Settings
The Pivot Engulfing Scalper was designed for liquid, momentum-prone instruments — major forex pairs such as EUR/USD and GBP/USD, or XAU/USD (gold) — traded on intraday timeframes of M5, M15, or M30. These markets tend to produce the alternating structural breaks and false breaks the strategy is built to read. Because the pivot range scales every buffer automatically, the EA runs on whatever symbol and timeframe you attach it to, but its behavior will differ across instruments and conditions. Results will vary significantly across different market environments — what works in a trending session may behave very differently in a tight, ranging one — so always study the strategy on each market before drawing conclusions.
How to Install on MetaTrader 5
- Download the
PivotEngulfingScalper.ex5file from the link below. - Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
This strategy has some genuine educational strengths. Because it uses no indicators, its logic is transparent and easy to study line by line — every entry traces back to a candle pattern and a structural level you can see on the chart. The pivot-range scaling means it adapts its buffers to volatility without manual pip tuning, and the basket money management gives it a clear, rule-based exit on both the profit and loss sides.
It also has real limitations you should understand. Breakout strategies are vulnerable to choppy, sideways markets, where levels are broken and reclaimed repeatedly — exactly the conditions that produce false breaks. The hedge mechanic is designed to handle some of these, but hedging is not a cure-all: holding both directions locks in the spread cost and can still lose if a strong one-way trend runs after the hedge is deployed, which is precisely why the hard BasketSlMoney ceiling exists. The engulfing pattern itself is common and can produce signals that fail to follow through. Because the EA banks profits at a fixed money basket level, its risk-to-reward profile depends heavily on how BasketTpMoney and BasketSlMoney are set relative to your lot size — a small profit target paired with a large loss ceiling is a configuration that demands caution. Treat every parameter as something to test and understand, not to optimize blindly.
Risk Management Tips
Sound risk management matters more than any single strategy. Consider these general principles:
- Risk only a small fraction per trade. Many educators suggest risking no more than 1–2% of account equity on any single setup. With a basket-style EA, think about your total exposure across all legs, not just one position.
- Size positions deliberately. Match your
Lotsand basket money levels to your account size so a worst-case flatten remains within your tolerance. - Always start on a demo account. Run the EA in a simulated environment first to observe how it behaves across different sessions and conditions before risking real capital.
- Understand drawdown. Even a well-built strategy will experience losing streaks. Know the maximum drawdown you are willing to accept and stop if it is reached.
- Account for spread and swap. Scalping and hedging are both sensitive to trading costs; factor them into your expectations.
- Never trade money you cannot afford to lose, and keep position sizes within your overall financial plan.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: PivotEngulfingScalper.ex5 (4 downloads)
- Source Code: PivotEngulfingScalper.mq5 (4 downloads)
- Documentation: PivotEngulfingScalper.pdf (3 downloads)