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 Hedge is a pure price-action expert advisor (EA) for MetaTrader 5 that combines Japanese candlestick patterns — specifically the engulfing pattern and the pin bar — with a rolling pivot point framework (the classic P / R1 / S1 levels) to time entries around support and resistance. A pivot point is a calculated reference price derived from recent highs, lows, and closes; R1 and S1 are the first resistance and support levels projected from it. Notably, the strategy uses no traditional indicators at all: there are no moving averages, no RSI, and no MACD. Every decision is made directly from raw candle data, which makes the logic transparent and easy to study.
The strategy is designed to operate in two complementary market conditions. In a ranging or mean-reverting market, it looks for reversal signals — a bullish engulfing candle or bullish pin bar that rejects a support zone, or a bearish counterpart that rejects a resistance zone. In a trending or expanding market, it looks for breakout signals — a strong-bodied candle that closes decisively beyond R1 or below S1. Layered on top is an optional hedge leg: if the primary trade runs against you by a measured amount, an opposite-side position opens automatically to cap further drawdown.
As a learning tool, the Engulfing Pivot Hedge suits intermediate traders who already understand basic candlestick reading and want to see how pattern recognition, dynamic support/resistance, volatility-based position sizing, and hedging logic fit together in one coherent system. It is best treated as a study in price-action mechanics rather than a turnkey solution, and it should be explored on a demo account first.
How It Works
The strategy evaluates new entries only once per newly-closed bar, while hedge management runs on every tick so an adverse move is caught promptly. Here is how the logic unfolds:
- Building the pivot framework: On each new bar, the strategy scans the most recent closed bars (the
PivotLookbackwindow) to find the highest high and lowest low. It then computes the pivotP = (High + Low + LastClose) / 3, the resistanceR1 = 2 × P − Low, and the supportS1 = 2 × P − High. These levels shift as the window rolls forward. - Measuring volatility: A custom "range proxy" averages the high-to-low range of the last
RangePeriodbars. This single number drives stop-loss distance, take-profit distance, the zone width, and the hedge trigger — keeping every threshold proportional to current market volatility. - Reversal entry (long): The strategy signals a long when the previous candle forms a bullish engulfing pattern or a bullish pin bar and that candle's low sits within a "zone" (a fraction of the range) of the S1 or P support level.
- Reversal entry (short): It signals a short when the previous candle forms a bearish engulfing or bearish pin bar and that candle's high sits within the zone of the R1 or P resistance level.
- Breakout entry (long): It signals a long when the previous candle closes above R1 plus the zone buffer and has a strong body — meaning the body is at least half the candle's full range, indicating conviction.
- Breakout entry (short): It signals a short when the candle closes below S1 minus the zone buffer with the same strong-body condition.
- One trade at a time: Only a single primary position is allowed per symbol. New signals are ignored while a primary trade is open.
- Stop-loss logic: The stop is placed at
SlRangeMult × rangeaway from entry, so wider markets get wider stops automatically. - Take-profit logic: The target is placed at
TpRangeMult × rangefrom entry. With the defaults (SL 1.0×, TP 1.5×), the strategy seeks a reward-to-risk ratio of roughly 1.5 to 1. - Hedge logic: If a primary long moves against you by
HedgeTrigger × range(price falls that far below your open price), an opposite short opens under a separate magic number, sized atLots × HedgeMult. The mirror applies to a primary short. Only one hedge per primary is opened, and it is meant to limit the damage when a reversal trade fails into a developing trend.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| PivotLookback | 20 | 10 | 60 | Number of closed bars used to find the high/low for the pivot, R1, and S1 levels. Larger values produce broader, slower-moving zones. |
| RangePeriod | 14 | 5 | 30 | Number of bars averaged in the range proxy that sizes stops, targets, zones, and the hedge trigger. |
| ZoneFrac | 0.50 | 0.10 | 2.0 | Width of the support/resistance "zone" as a fraction of the range. Larger values make proximity checks and breakout buffers more lenient. |
| SlRangeMult | 1.00 | 0.30 | 3.0 | Stop-loss distance as a multiple of the range proxy. |
| TpRangeMult | 1.50 | 0.50 | 5.0 | Take-profit distance as a multiple of the range proxy. |
| HedgeTrigger | 1.00 | 0.30 | 3.0 | Adverse move, as a multiple of the range, that triggers the opposite-side hedge leg. |
| HedgeMult | 1.00 | 0.50 | 2.0 | Volume multiplier applied to the hedge leg relative to the primary lot size. |
| Lots | 0.10 | 0.01 | 1.0 | Primary trade volume in lots. |

Recommended Chart Settings
Because the Engulfing Pivot Hedge relies on clean candlestick patterns and pivot structure, it tends to be studied most naturally on the major forex pairs — such as EUR/USD or GBP/USD — where spreads are tight and price action is liquid. Intraday timeframes like the M15 (15-minute) or H1 (1-hour) chart give the pattern-and-pivot logic enough bars to form meaningful zones while still producing scalp-style targets. As always, the optimal symbol, timeframe, and parameter set depend on the instrument's behavior, and results will vary considerably across different market conditions. Treat any setting as a starting point for your own testing rather than a fixed recommendation.
How to Install on MetaTrader 5
- Download the
EngulfingPivotHedge.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
The Engulfing Pivot Hedge has several genuine strengths as a study tool. Its logic is fully transparent — with no indicator handles, you can trace every entry back to specific candle and pivot math. Sizing stops, targets, zones, and the hedge trigger from a shared volatility proxy is an elegant design that adapts thresholds to the market automatically. The dual reversal-and-breakout approach also means the system has a mode for both ranging and trending conditions.
There are equally important limitations to understand. Engulfing patterns and pin bars are common and can produce false signals, especially during low-volatility chop where candles overlap noisily. Pivot levels recalculated from a rolling window can drift, and price does not always respect them. The breakout leg can be vulnerable to "fakeouts" where price closes beyond a level only to snap back.
The hedging component deserves particular caution. Hedging does not eliminate risk — it can lock in a loss on both legs if price whipsaws, and it increases total exposure and commission costs. Some brokers and jurisdictions restrict hedging or apply FIFO rules that prevent it entirely. The strategy may underperform in strongly trending markets where reversal entries repeatedly fail, and in very quiet markets where the range proxy shrinks and stops sit uncomfortably tight. Forward-test thoroughly before drawing any conclusions.
Risk Management Tips
Sound risk management matters more than any single entry rule. 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 one position. Choose your
Lotsvalue accordingly, and remember the hedge leg adds further exposure. - Account for the hedge in your sizing. Because
HedgeMultcan scale the second leg, your true maximum exposure may exceed the primary lot size. Size with the combined position in mind. - Start on a demo account. Test the EA in a simulated environment until you understand how it behaves across ranging, trending, and volatile sessions.
- Understand drawdown. Review how deep and how long historical equity dips run before committing real capital, and make sure you could tolerate a similar stretch emotionally and financially.
- Use a stop-loss always. The built-in range-based stop is essential; never disable it in pursuit of "giving the trade room."
- Keep position sizes consistent and avoid increasing risk after losses to "win it back."
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: EngulfingPivotHedge.ex5 (2 downloads)
- Source Code: EngulfingPivotHedge.mq5 (3 downloads)
- Documentation: EngulfingPivotHedge.pdf (2 downloads)