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 Engulfing Pivot Breakout is a pure price-action expert advisor (EA) for MetaTrader 5 that combines three classic chart-reading tools — floor pivot points, the engulfing candlestick pattern, and a momentum breakout entry — without relying on a single lagging indicator. There is no moving average, RSI, ATR, or Bollinger Band anywhere in its logic. Instead, it reads raw candles and rolling support/resistance levels, making it a useful study piece for traders who want to understand how structure-based systems are built.
A pivot point is a calculated fair-value line for a session: the central pivot (PP) sits at the average of the recent high, low, and close, while R1 and S1 act as the nearest resistance and support "magnets" above and below it. An engulfing candle is a two-bar reversal pattern where one candle's body completely covers the previous candle's body, signalling that momentum has shifted from one side to the other. The strategy fuses these ideas: when a wide engulfing candle reclaims the central pivot from the losing side, the EA treats it as a sign that control has flipped and looks for a quick continuation move toward the next pivot.
This EA is designed for liquid, mean-reverting-then-impulsive markets — FX majors such as EUR/USD, GBP/USD, and AUD/USD, or gold (XAU/USD) — where price repeatedly tests a pivot, breaks it, and either follows through or snaps back. It is best suited as a learning tool for intermediate traders who want to see how pivot reclaims, candlestick confirmation, and hedged money management can be expressed in code. It is not a shortcut to results, and the sections below treat it strictly as an analysis exercise.
How It Works
The strategy recomputes its levels on every closed bar and only opens a new base trade when the account is completely flat. Here is the logic in plain English.
Calculating the pivots
- Over the last
PivotLookbackclosed bars, the EA finds the highest high (H), the lowest low (L), and the most recent close (C). - It then derives PP = (H + L + C) / 3, R1 = 2 × PP − L, and S1 = 2 × PP − H.
- The pivot range (R1 − S1, which equals H − L) is used to size every buffer and stop, so all distances scale automatically to any symbol or timeframe with no hard-coded pip values.
Long entry — the strategy signals a bullish reclaim
- The just-closed candle is a bullish engulfing (a green body that fully covers the prior red body).
- That candle opened at or below PP and closed clearly above PP by at least the
BreakBufferFracbuffer. - The engulfed bar closed below PP, confirming bulls reclaimed equilibrium from below.
- The body must be a dominant momentum body (large versus its own high-low range, set by
BodyDomFrac) and significant versus the pivot range (MinBodyFrac). - When all conditions align, the EA buys with a take-profit at R1, the next pivot magnet above.
Short entry — the mirror image
- The just-closed candle is a bearish engulfing that opened at or above PP and closed clearly below it, with the engulfed bar above PP.
- The same momentum and significance filters apply, and the EA sells toward S1.
Stop-loss and take-profit logic
- The base take-profit is the next pivot magnet (R1 for longs, S1 for shorts), with a minimum reward floor set by
RewardFrac. - The base stop-loss is placed a structural pad (
StopFrac) beyond the hedge trigger, so the hedge always engages before the stop.
The signature hedge mechanic
- While the single base leg is open, if price travels
FailFracof a range back beyond PP, the reclaim is judged to have failed (a false break). - The EA then opens an opposite market leg, holding both directions in a genuine locked hedge that rides the snap-back and offsets the losing base leg.
Basket money management
- Whenever any exposure is held, net floating profit/loss is the dominant exit.
- If net floating P/L reaches
BasketTpMoney, the EA closes everything and banks the result. - If net floating P/L falls to −
BasketSlMoney, the EA flattens the basket as a hard ceiling on risk — important because the failure mode after a hedge locks is a strong one-way trend.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 20 | 5 | 150 | Number of closed bars whose H/L/C define the rolling floor pivots. |
| BreakBufferFrac | 0.05 | 0.00 | 0.50 | How far past PP (as a fraction of the pivot range) the close must clear to count as a clean reclaim. |
| BodyDomFrac | 0.55 | 0.30 | 0.95 | Minimum engulfing body size as a fraction of its own high-low range (momentum filter). |
| MinBodyFrac | 0.18 | 0.03 | 1.50 | Minimum engulfing body size as a fraction of the pivot range (significance filter). |
| FailFrac | 0.25 | 0.05 | 1.00 | Distance back beyond PP that confirms the reclaim failed and deploys the hedge. |
| StopFrac | 0.30 | 0.05 | 2.00 | Extra base-stop pad placed beyond the hedge trigger (fraction of the pivot range). |
| RewardFrac | 1.00 | 0.20 | 4.00 | Minimum reward distance for the base take-profit (fraction of the pivot range). |
| 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 exceeds this many points (0 = off). |
| Lots | 0.10 | 0.01 | 1.00 | Base and hedge leg volume. |
| Magic | 8310 | 0 | 9999999 | Magic number used to identify this EA's positions. |

Recommended Chart Settings
The Engulfing Pivot Breakout was designed for liquid FX majors — EUR/USD, GBP/USD, AUD/USD — or XAU/USD (gold), on the M5, M15, or M30 timeframes, where pivot reclaims and false breaks tend to alternate. The pivot math scales automatically, so the EA runs on whatever timeframe is selected at backtest without manual pip tuning. Keep in mind that results will vary considerably across different instruments, brokers, and market conditions; a setting that behaves one way during a ranging session may behave very differently during a strong trend or a news spike.
How to Install on MetaTrader 5
- Download the
EngulfingPivotBreakout.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
Strengths of the approach. Because the system reads price action directly, it has no indicator lag and adapts its distances to each symbol's volatility through the pivot range. The engulfing filter, the buffer clearance, and the two body-size checks together demand genuine momentum before an entry, which historically helps screen out weak, noisy signals. The basket exit also gives the strategy a single, money-based decision point that is easy to reason about.
Known limitations. Pivot points and engulfing candles are popular precisely because they are simple, and simple patterns produce many false signals. The hedge mechanic is the part that most deserves caution: once both legs are locked, the position can only be resolved by the basket take-profit, the basket stop, or one leg's stop. In a strong, sustained trend that runs straight through PP without snapping back, the hedge offers little protection and the basket can drift toward its BasketSlMoney ceiling. Likewise, in a tight, low-volatility range the engulfing momentum filters may rarely trigger at all, leaving long stretches with no trades.
Where it may underperform. Thin liquidity, wide spreads, and news-driven gaps can all distort pivot levels and slip stops. The fixed-lot sizing means risk does not adapt to account size, and holding two opposing legs ties up margin. Treat this EA as a structured example of how pivots, candlesticks, and hedging interact — not as a finished system — and study its behaviour in the Strategy Tester before drawing any conclusions.
Risk Management Tips
Sound risk management matters far more than any single entry rule. As a general educational guideline:
- Risk only a small fraction of your account per trade — many educators suggest no more than 1–2%. Set
Lots,BasketSlMoney, andBasketTpMoneyso the worst-case basket loss stays within that limit. - Always test on a demo account first. Run the EA in the MT5 Strategy Tester and on a demo for an extended period before considering any live use.
- Understand drawdown. Even a well-constructed system experiences losing streaks; know the largest peak-to-trough decline you could tolerate, both financially and emotionally.
- Account for spread and swap. Hedged, multi-day positions can accrue swap costs that erode results.
- Never trade with money you cannot afford to lose, and consider position sizing relative to your total capital rather than a single trade in isolation.
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: EngulfingPivotBreakout.ex5 (3 downloads)
- Source Code: EngulfingPivotBreakout.mq5 (5 downloads)
- Documentation: EngulfingPivotBreakout.pdf (3 downloads)