Engulfing Pattern EA
This is a published price-action pattern, offered here for study and as a template to adapt, not a guaranteed edge. A bullish engulfing bar opens below the prior bar's close and closes above the prior bar's open, enclosing the whole of the previous body; a bearish engulfing bar does the mirror. Both are read as a one-bar shift in who is in control. The detection here requires the current body to fully enclose the prior body (open beyond the prior close, close beyond the prior open) rather than merely closing past the prior close, which is a stricter and less noisy definition than some published variants use - it filters out a lot of marginal candles that technically qualify under the looser rule but carry little of the pattern's actual signal. InpUseTrendFilter, on by default, only allows a bullish engulfing signal above InpTrendMaPeriod's moving average and a bearish signal below it. Engulfing patterns traded against the prevailing direction are the ones most likely to be noise rather than reversal, which is the specific failure mode this filter exists to reduce. Entry is at market, on the bar immediately following the confirmed engulfing close - the pattern is only valid once the bar has actually closed, so entry cannot happen mid-formation. The stop-loss sits beyond the wider of the engulfing bar's own extreme and the bar it engulfed, plus InpStopLossBufferPips. Notes and limitations - One position at a time, tracked by InpMagicNumber. A new signal is ignored while a position from this EA is already open. - Entry is at market on the bar after the pattern closes, so slippage and any gap between that close and the next bar's open price are part of the fill, not something the EA can avoid. - The trend filter uses a same-timeframe moving average, not a genuinely higher timeframe - it approximates trend context without adding a second data series. - Requires AutoTrading enabled and trading permitted at the terminal, account and program level; if trading is disabled the EA logs it and skips the entry. - On MQL5 netting, this EA refuses a new entry outright if a foreign- magic position already sits on the symbol, rather than risk merging into it. - A published pattern, not a strategy with a documented statistical edge on any specific symbol - test on your own data before trusting it.
Expert advisor · MT5 · v1.0 · Free
About Engulfing Pattern EA
Engulfing Pattern EA is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It can size trades from your balance and risk percent. It has 12 settings, such as Use trend filter, Trend ma period and Trend ma method. MQL source code included.
Files in the download: EngulfingEa.ex5, EngulfingEa.mq5, EngulfingEa.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Use trend filter | true | Only take engulfing signals that agree with the moving average below |
| Trend ma period | 50 | Period of the trend filter moving average |
| Trend ma method | MODE_EMA | Method of the trend filter moving average |
| Stop loss buffer pips | 5 | Pips beyond the engulfing bar's extreme for the stop-loss |
| Reward multiple | 1.5 | Take-profit as a multiple of the stop distance (0 = no take-profit) |
| Use risk sizing | false | Size by percent risk instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a fallback |
| Magic number | 20260818 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Price Action · Candlestick Patterns · Trend · Risk & Lot Size · Moving Average · MT5 Expert Advisor · MQL5 Source Code