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 Hedge is a pure price-action expert advisor (EA) for MetaTrader 5 that combines three classic tools — floor pivot levels, the engulfing candlestick pattern, and a managed hedge — into a single intraday breakout system. It uses no lagging indicators at all: there is no moving average, RSI, ATR, or Bollinger Band anywhere in its logic. Every decision is made from raw open, high, low, and close prices, which keeps the strategy transparent and easy to study.
At its core, the strategy is a momentum-breakout approach. Floor pivots are reference price levels (a central pivot point plus support and resistance levels) that intraday desks watch and defend. An engulfing candle is a two-bar reversal pattern where the most recent candle's body completely swallows the prior candle's body, signalling that one side has decisively taken control. The Pivot Engulfing Hedge waits for a full-bodied engulfing candle to close cleanly through a pivot level — interpreting that as one side overwhelming the other right where the whole market is looking — and trades in the direction of the break.
This EA is best suited to traders who want to learn how breakout-and-hedge mechanics work rather than those seeking a hands-off solution. Because it includes a hedge leg (an opposite position opened when a breakout fails), it is a useful case study in how some systems attempt to manage false breakouts. It is designed for liquid, level-respecting markets such as the EUR/USD, GBP/USD, or XAU/USD (gold) on intraday timeframes, where genuine pivot breaks and false breaks tend to alternate.
How It Works
The strategy recalculates its floor pivots on every freshly closed bar using only the primary chart timeframe. Over the last PivotLookback closed bars it finds the highest high (H), lowest low (L), and most-recent close (C), then derives:
- Pivot Point (PP) = (H + L + C) ÷ 3
- Resistance 1 (R1) = (2 × PP) − L
- Support 1 (S1) = (2 × PP) − H
The "pivot range" (H − L, which equals R1 − S1) is used to size every buffer and target. Because all distances are expressed as a fraction of that range, the system scales to any symbol or timeframe with no hard-coded pip values.
Entry conditions (the strategy only looks for new trades when flat):
- Long signal — the just-closed candle is a bullish engulfing (its body engulfs the prior bearish body and is at least
EngulfRatiotimes larger), the previous close sat at or below a pivot, and this candle closes clearly above that pivot by theBreakFractolerance. This is read as momentum breaking up. - Short signal — the mirror image: a bearish engulfing candle whose body engulfs the prior bullish body, where price was at or above a pivot and now closes clearly below it. This is read as momentum breaking down.
- When more than one pivot qualifies, the strategy selects the strongest break — the highest pivot cleared on a long, or the lowest pivot broken on a short.
Stop-loss logic:
- The base stop-loss is placed a structural pad (
StopFracof the range) beyond the hedge trigger, so the hedge mechanic engages before the base stop is ever reached. - The code also enforces the broker's minimum stop distance, nudging the stop to a valid level if needed.
Take-profit and the hedge:
- The base take-profit is a reward-multiple scalp distance (
RewardFracof the range) away from entry. - While the single base leg is open, if price travels
HedgeFracof a range back across the broken pivot, the breakout is treated as a false break. The strategy then deploys an opposite hedge leg — a locked position intended to ride the snap-back reversal and offset the trapped base leg. - The
ReclaimFracpad defines where the hedge itself would be considered wrong (price reclaiming the original breakout side).
Basket exits (the dominant exit once any position is held):
- If net floating profit across all legs reaches
BasketTpMoney, the strategy closes everything — banking the scalp or recovery. - If net floating loss reaches
BasketSlMoney, it flattens the whole basket as a hard ceiling, protecting against a strong one-way trend after the hedge locks. - New entries are skipped while the spread (in points) exceeds
MaxSpreadPoints.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 24 | 5 | 150 | Number of closed bars whose H/L/C define the floor pivots. |
| BreakFrac | 0.10 | 0.00 | 0.60 | How far beyond a pivot the engulfing must close to confirm the break (fraction of the pivot range). |
| EngulfRatio | 1.10 | 1.00 | 4.00 | The engulfing body must be at least this multiple of the prior body (strength filter). |
| HedgeFrac | 0.25 | 0.05 | 1.00 | Pullback back across the broken pivot that confirms a false break and deploys the hedge. |
| StopFrac | 0.30 | 0.05 | 2.00 | Extra base-stop pad placed beyond the hedge trigger (fraction of the range). |
| RewardFrac | 1.00 | 0.20 | 4.00 | Base take-profit scalp distance from entry (fraction of the range). |
| ReclaimFrac | 0.30 | 0.05 | 1.50 | Hedge invalidation pad — if price reclaims the breakout side by this, the hedge is deemed wrong. |
| 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 spread (points) exceeds this (0 = off). |
| Lots | 0.10 | 0.01 | 1.00 | Trade volume per leg. |
| Magic | 8310 | 0 | 9,999,999 | Magic number used to identify this EA's positions. |

Recommended Chart Settings
The Pivot Engulfing Hedge was designed for liquid FX majors such as EUR/USD and GBP/USD, or XAU/USD (gold), on intraday timeframes of M5, M15, or M30 — the conditions where pivot breaks and false breaks tend to alternate. Because every distance scales to the pivot range, it will technically run on any symbol and timeframe selected at backtest time, but its behaviour was conceived around these instruments.
Importantly, the hedge mechanic requires a hedging account so that opposite legs can be held at the same time. On a netting account, an opposite order will net (reduce) the base leg instead of locking it, which changes the strategy entirely — the MQL5 version logs a warning in this case. Results will vary considerably across different brokers, spreads, and market conditions, so treat any single configuration as a starting point for study rather than a finished setup.
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's logic is fully transparent and indicator-free, which makes it an excellent learning tool for understanding pivots, engulfing patterns, and breakout confirmation. Its range-relative sizing means there are no magic pip numbers to retune for each symbol. The hedge-and-basket design is also an instructive example of how some systems try to recover from false breakouts rather than simply taking the loss.
Known limitations. Hedging strategies are not a free lunch. When a hedge locks in an opposing pair, a strong, sustained one-way trend can carry both legs into a widening net loss until the BasketSlMoney ceiling flattens the basket — which is why that hard limit exists. Engulfing breakouts can also fail repeatedly in choppy, low-volatility conditions, producing a series of small losing baskets. Because the EA holds floating positions and relies on net P/L exits rather than tight per-trade stops, drawdown can build during difficult periods.
Where it may underperform. Quiet, range-bound sessions with frequent fakeouts, news-driven spikes that blow through stop distances, and high-spread instruments can all degrade results. Always confirm your broker offers a hedging account and realistic spreads before relying on this logic. Historically, no breakout pattern wins every time — the goal of studying this EA is to understand how the components interact, not to expect a particular outcome.
Risk Management Tips
Sound risk management matters far more than any single entry signal. Consider these general principles as you study this strategy:
- Use a demo account first. Run the EA on a demo for an extended period across varied market conditions before ever considering live capital.
- Risk only a small fraction per idea. A common guideline is to risk no more than 1–2% of account equity on any single trade or basket. Size your
Lots,BasketSlMoney, and account balance accordingly. - Understand drawdown. Hedged baskets can sit in floating loss for extended periods. Know your maximum tolerable drawdown in advance and respect it.
- Mind position sizing. Larger lots magnify both gains and losses; keep volume conservative while you are still learning the system's behaviour.
- Keep records. Track how often false breaks resolve into successful hedges versus losing baskets so you understand the strategy's real character.
These are educational principles, not guarantees — every trader's circumstances differ, and you remain responsible for your own decisions.
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: PivotEngulfingHedge.ex5 (4 downloads)
- Source Code: PivotEngulfingHedge.mq5 (3 downloads)
- Documentation: PivotEngulfingHedge.pdf (3 downloads)