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?
Engulfing Pivot Guard is a pure price-action expert advisor (EA) for MetaTrader 5 that combines two classic tools — floor pivot points and the engulfing candlestick pattern — into a single intraday system. A floor pivot is a set of reference levels (a central pivot PP, a resistance level R1, and a support level S1) calculated from recent highs, lows, and closes. An engulfing pattern is a two-candle formation in which the most recent candle's body completely "swallows" the prior candle's body, a sign that order flow has flipped from one side of the market to the other. Notably, this strategy uses no traditional indicators — there is no moving average, RSI, ATR, or Bollinger Band anywhere in its logic.
The strategy is designed for range-respecting, mean-reverting market conditions — the kind of environment where price repeatedly tests support and resistance and rotates back toward a central value. It interprets an engulfing candle differently depending on where it forms: at an outer pivot (R1 or S1) it treats the engulf as exhaustion and trades a reversal back to the central pivot; at the central pivot it treats the engulf as acceptance and trades a breakout toward the next outer level. Because every distance is measured as a fraction of the pivot range rather than in hard-coded pips, the system scales automatically across symbols and timeframes.
As a learning tool, Engulfing Pivot Guard is well suited to traders who want to study how candlestick patterns interact with structural levels, and how a hedging — or "guard" — mechanic can be used to manage a trade that moves against the original idea. This article frames the EA as a strategy analysis, not a profit opportunity. The goal is to help you understand the mechanics so you can evaluate the approach critically.
How It Works
The strategy recomputes its pivots on every closed bar using the highest high (H), lowest low (L), and the signal candle's close (C) over the most recent PivotLookback bars: PP = (H + L + C) / 3, R1 = 2·PP − L, S1 = 2·PP − H. The pivot range (H − L) sizes every buffer and target.
Entry conditions (the strategy only seeks new trades when flat):
- Reversal Long — the strategy signals a buy when a bullish engulf forms with its low dipping into the S1 support zone but closing back above S1. This may indicate seller exhaustion, and the trade targets the central pivot PP.
- Reversal Short — the strategy signals a sell when a bearish engulf pierces the R1 resistance zone but closes back below R1, potentially indicating buyer exhaustion, again targeting PP.
- Breakout Long — when a bullish engulf closes clearly above PP from the PP zone, the strategy signals acceptance to the upside and targets R1.
- Breakout Short — when a bearish engulf closes clearly below PP, the strategy signals downside acceptance and targets S1.
Reversal setups are checked before breakout setups so that a single candle near the pivot cannot trigger both.
Stop-loss logic:
- The base stop is placed a structural pad beyond the "guard trigger," so the hedge always engages before the hard stop is hit.
- Distances respect the broker's minimum stop level, so orders are not rejected.
Take-profit logic:
- The base take-profit is the structural pivot target (S1 → PP, PP → R1, and the mirror images), creating a clean "pivot-to-pivot" scalp.
- A minimum reward distance (
RewardFracof the range) is enforced so very tight setups are widened to a sensible target.
The guard / hedge mechanic is the signature feature:
- While a single base leg is open, if price travels
GuardFracof a range beyond the leaned-on level — meaning the level has failed — the strategy opens an opposite market leg, a genuine locked hedge that rides the break the new way. - If price later reclaims the level by
ReclaimFracof a range in the base's favour, the guard is dropped (the hedge is closed) and the base is left to recover.
Basket money management is the dominant exit while any exposure is held:
- If net floating profit reaches
BasketTpMoney, the strategy closes everything. - If net floating loss reaches
BasketSlMoney, the strategy flattens the whole basket as a hard ceiling — the worst case being a strong one-way trend after the guard locks.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 24 | 5 | 150 | Number of closed bars whose high/low/close define the floor pivots. |
| EngulfFactor | 1.00 | 0.80 | 3.00 | Engulfing body must be at least this multiple of the prior body (≥1 = full engulf). |
| ZoneFrac | 0.12 | 0.02 | 0.60 | How close to a pivot the signal candle must reach, as a fraction of the pivot range. |
| GuardFrac | 0.25 | 0.05 | 1.00 | Distance beyond the leaned-on level that confirms it failed and raises the guard. |
| StopFrac | 0.30 | 0.05 | 2.00 | Extra base-stop pad placed beyond the guard trigger (fraction of the pivot range). |
| ReclaimFrac | 0.20 | 0.05 | 1.50 | Reclaim past the level, in the base's favour, that drops the guard (fraction of range). |
| RewardFrac | 0.70 | 0.20 | 4.00 | Minimum reward distance for the base take-profit (fraction of the pivot range). |
| BasketTpMoney | 25.0 | 5.0 | 2000.0 | Close the whole basket once net floating profit reaches this (account currency). |
| BasketSlMoney | 300.0 | 50.0 | 100000.0 | Flatten the whole basket once net floating loss reaches this (account currency). |
| MaxSpreadPoints | 50 | 0 | 500 | Skip new entries while the spread (in points) exceeds this value (0 = off). |
| Lots | 0.10 | 0.01 | 1.00 | Base and guard trade volume in lots. |
| Magic | 5310 | 0 | 9,999,999 | Unique EA magic number used to identify this strategy's positions. |

Recommended Chart Settings
Engulfing Pivot Guard was designed for liquid, range-respecting FX majors such as EUR/USD or AUD/USD, or for gold (XAU/USD), on the M15, M30, or H1 timeframes — environments where pivot exhaustion and acceptance tend to alternate. Because all distances scale with the pivot range, the EA runs on whichever timeframe is selected at the time, with no pip values to retune. Keep in mind that results will vary considerably across different symbols, brokers, and market conditions, and that a setup that historically behaved well in a ranging market may behave very differently when a strong trend develops.
How to Install on MetaTrader 5
- Download the .ex5 file 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. The strategy is conceptually clean: it relies on a single, well-defined candlestick trigger and well-known structural levels, with no lagging indicators to second-guess. Its pivot-relative sizing means it adapts to volatility automatically, and the guard mechanic gives it a defined response when a level fails rather than simply absorbing a full stop. Trading only when flat keeps the logic transparent and easy to study.
Known limitations. Engulfing patterns are common and not all of them mark genuine reversals or breakouts, so false signals are an inherent part of the approach. Pivot levels are not magical — price can slice straight through them, especially around news. Most importantly, the hedging / basket design carries a specific risk profile: when a level fails and the guard locks the position, a strong one-way trend can push the basket toward its BasketSlMoney ceiling. In that scenario, the loss realized in one event can be larger than the small, frequent gains the system is designed to bank — a classic characteristic of basket-and-hedge systems that you should understand fully before risking capital.
Where it may underperform. Trending or strongly breaking markets, illiquid sessions with wide spreads, and instruments that do not respect intraday pivots are all conditions where this mean-reversion-leaning logic may struggle. The MaxSpreadPoints filter helps avoid the worst spread conditions, but it cannot protect against sustained directional moves.
Risk Management Tips
Sound risk management matters more than any single entry rule. Consider the following general principles as you study this EA:
- Test on a demo account first. Run the strategy on a demo or on historical data in the Strategy Tester for an extended period before committing any real funds, and observe how it behaves through both ranging and trending phases.
- Risk only a small fraction per idea. A widely cited guideline is to risk no more than 1–2% of account equity on any single trade or basket. With a hedging system, size your
BasketSlMoneyso that hitting it represents an acceptable loss relative to your account. - Understand drawdown. Examine the largest peak-to-trough decline the strategy historically produced, and ask whether you could tolerate it both financially and psychologically.
- Match position size to account size. The default
Lotsvalue may be too large for a small account; scale volume to your equity rather than the other way around. - Keep expectations realistic. No strategy wins every trade, and basket systems in particular can trade a long string of small results around occasional larger losses.
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: EngulfingPivotGuard.ex5 (3 downloads)
- Source Code: EngulfingPivotGuard.mq5 (3 downloads)
- Documentation: EngulfingPivotGuard.pdf (3 downloads)