Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

Inside Bar Engulfing Scanner - indicator for MetaTrader 5

Cristhian Alexander Gaibor Cuasquer
Cristhian Alexander Gaibor Cuasquer
  • Founder & Systems Engineer at  Xander Pro
  • Ecuador
  • 9264
4.7 (40)
Trader and MQL5 member since 2017.
Views:
11
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

On Gold (XAUUSD) two candle patterns come up again and again: the engulfing candle and the inside bar. This indicator reads every closed candle against the one before it. A bullish engulfing is a bearish candle followed by a bullish one whose body covers it, a bearish engulfing is the mirror, and an inside bar is a candle whose high and low stay inside the previous one.

Bullish engulfing gets an arrow under the low, bearish engulfing an arrow over the high and the inside bar a dot. For the newest inside bars the mother bar range is drawn as a box that runs a few bars to the right, so you can see which side breaks. The forming candle is never marked, so nothing appears and then vanishes.

A pattern is a reason to look, not an entry by itself. You can ask for a minimum body in ATR and an EMA trend filter, but the code does not judge where the pattern formed.

Inside Bar Engulfing Scanner on a XAUUSD H1 chart in MetaTrader 5: arrows on bullish and bearish engulfing candles, dots and mother bar boxes on inside bars

Settings

  • Bullish engulfing, bearish engulfing and inside bar: switch each pattern on or off.
  • Engulfing rule: the body covers the previous body (default), or the body covers the previous full candle from high to low. In both cases the body must be bigger than the previous body.
  • Minimum body of the engulfing candle: in ATR, default 0 (off). ATR period: default 14, also used for the arrow distance.
  • Inside bar may touch the mother bar high or low: off by default, so the inside bar has to stay strictly inside.
  • Trend EMA period: default 0 (off). When it is on, bullish engulfing only counts above the EMA and bearish engulfing only below it.
  • Arrow distance in ATR (default 0.3), colours, box on the mother bar range (on), bars the box extends (5), maximum boxes (5, newest first) and bars to scan (2000, 0 = all).
  • Alerts: one switch per pattern, all off by default. Popup, push and sound, once on the candle that just closed.
  • Object prefix: change it to run two copies on the same chart.

What it needs

Any symbol and any timeframe. It reads the built-in ATR, and the built-in EMA only when the trend filter is on. The three patterns are arrow buffers (0 bullish engulfing, 1 bearish engulfing, 2 inside bar, empty value when there is no pattern), so an EA can read them with iCustom on bar 1. It never trades. Push notifications need your MetaQuotes ID in the terminal options.

Make it yours

Run it on XAUUSD, XAGUSD, EURUSD, GBPUSD, US30 or NAS100 and compare M15, H1 and H4. Try the body rule against the full candle rule and see how many signals each one leaves. Engulfing candles at a support and resistance level or at a Smart Money Concepts order block are a common next step. XP_Pattern holds the three rules in one function and returns a code you can copy straight into your own EA, and a session filter can be added in the main loop.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it. Questions, suggestions and your own tests are welcome in the comments below. Provided as is, use at your own risk.

Related: Supply Demand Zones, Order Blocks Zones, Supertrend Gold Signals, Candle Timer Countdown.

Changelog

v1.0 (2026-11-30): initial release.

Hotkeys: keyboard shortcuts for MQL5 experts and indicators, set in the inputs Hotkeys: keyboard shortcuts for MQL5 experts and indicators, set in the inputs

One include file that gives your EA or indicator keyboard shortcuts the user types into the inputs, such as Shift+B. Each press fires one action, Shift+B never fires on a plain B, and a shortcut that cannot work is refused at start with the reason.

Daily loss and max loss guard - prop firm rules in one include Daily loss and max loss guard - prop firm rules in one include

Watches the equity like a prop firm does: daily loss limit and max loss limit, static or trailing, floating profit included. Stops new trades at a warning level, closes everything on a breach and remembers it after a restart.

Multi Timeframe Trend Dashboard Multi Timeframe Trend Dashboard

Multi timeframe trend dashboard for Gold (XAUUSD) and any symbol on MT5. Shows up, down or flat for up to 6 timeframes from a fast and slow EMA on the last closed bar, with the distance in points and an alert when all line up. Open source code.

Round Number Levels Session Grid Round Number Levels Session Grid

Round number levels for Gold (XAUUSD) and any symbol on MT5. Draws major and minor round levels around price plus Asia, London and New York session open lines, with an optional alert when a candle closes across a major level. Open source code.