# Candlestick Pattern Indicator (Engulfing, Pin Bar, Inside Bar) for MT5

> Marks bullish and bearish engulfing candles, pin bars (hammer and shooting star) and inside bars on closed candles, with clear rules and optional alerts.

## At a glance

- What it is: A free Indicator for MetaTrader 5, written in MQL5.
- What it does: Marks bullish and bearish engulfing candles, pin bars (hammer and shooting star) and inside bars on closed candles, with clear rules and optional alerts.
- Shared by: Alex
- Licence: MIT
- Version: 1.0 (1 Dec 2026)
- Settings: 15 inputs
- Lab check: Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
- Price: Free to download
- Page: https://hub.fxnook.com/candlestick-pattern-indicator-engulfing-pin-bar-inside-bar-for-mt5
- Download (compiled): https://hub.fxnook.com/download/39c5a443-f409-4ff6-bafb-f4062e6babfb/compiled
- Download (source): https://hub.fxnook.com/download/39c5a443-f409-4ff6-bafb-f4062e6babfb/source

## About

Engulfing candles, pin bars and inside bars are the core of many price action methods. This indicator checks every closed candle with fixed, written rules and marks the patterns with arrows and short labels, so you do not miss them and can review them consistently.

## How it works

The average range is the mean of `high - low` over the previous `Average range bars` candles. For engulfing and pin bars the candle range must be at least `Minimum size` x that average, which ignores tiny candles.

- **Bullish engulfing:** previous candle bearish, current candle bullish, current open at or below the previous close, current close at or above the previous open, and a bigger body.
- **Bearish engulfing:** the mirror image.
- **Hammer (bullish pin bar):** lower wick at least `Pin wick` x the body and at least `Pin wick %` of the range; upper wick at most `Pin nose %` of the range.
- **Shooting star (bearish pin bar):** the mirror image with the upper wick.
- **Inside bar:** high and low both inside the previous candle's range, with a smaller range.

Bullish patterns get an up arrow below the candle, bearish patterns a down arrow above it, inside bars a small diamond. Labels show the pattern names, for example "Engulfing + Hammer" or "IB".

## Inputs

| Input | Default | What it does |
|---|---|---|
| Engulfing / Pin bars / Inside bars | true | Turn each pattern on or off |
| Pin wick | 2.0 | Long wick at least this many bodies |
| Pin wick % | 60 | Long wick at least this % of the candle |
| Pin nose % | 25 | Other wick at most this % of the candle |
| Minimum size | 0.5 | Candle at least this x the average range (0 = off) |
| Average range bars | 14 | Bars for the average range |
| History bars | 3000 | Bars to scan (0 = all) |
| Show labels | true | Pattern names next to the arrows |
| Bullish / bearish / inside colour | SeaGreen / Crimson / Goldenrod | Colours |
| Label font size | 7 | Text size |
| Alerts | false | One alert when a closed candle forms a pattern |

## How to use it

1. In MetaTrader open **File > Open Data Folder**.
2. MT4: copy `FXN_CandlePatterns.mq4` into `MQL4/Indicators`. MT5: copy `FXN_CandlePatterns.mq5` into `MQL5/Indicators`.
3. Right-click **Indicators** in the Navigator and choose **Refresh** (or restart the terminal). The file compiles on first use; you can also open it in MetaEditor and press Compile.
4. Drag the indicator onto a chart and set the inputs.

The defaults suit H1 to D1. On lower timeframes raise `Minimum size` to 0.8-1.0 to filter noise. Patterns carry more weight at levels that matter: support and resistance, a fair value gap, or in the direction of the higher-timeframe trend. Turn off the patterns you do not use to keep the chart clean.

## Good to know

- **Closed candles only.** The forming candle is never marked, so arrows do not appear and disappear.
- The rules do not check the trend before the pattern; a hammer here is a shape, wherever it forms.
- The three arrow buffers can be read with iCustom; empty candles hold EMPTY_VALUE.
- It marks patterns only and does not trade.

Trading carries risk. Test on a demo account first; past results do not predict future results.

## Settings (inputs)

| Input | Type | Default | Note |
|---|---|---|---|
| InpEngulfing | bool | true | Bullish / bearish engulfing |
| InpPinBar | bool | true | Pin bars (hammer / shooting star) |
| InpInsideBar | bool | true | Inside bars |
| InpPinWick | double | 2.0 | Pin bar: long wick at least this many bodies |
| InpPinWickPct | double | 60.0 | Pin bar: long wick at least this % of the candle |
| InpPinNosePct | double | 25.0 | Pin bar: other wick at most this % of the candle |
| InpMinRange | double | 0.5 | Engulfing / pin: candle at least this x average range (0 = off) |
| InpAvgBars | int | 14 | Bars used for the average range |
| InpMaxBars | int | 3000 | History bars to scan (0 = all bars) |
| InpShowLabels | bool | true | Write the pattern name next to the arrow |
| InpBullColor | color | clrMediumSeaGreen | Bullish colour |
| InpBearColor | color | clrCrimson | Bearish colour |
| InpInsideColor | color | clrGoldenrod | Inside bar colour |
| InpFontSize | int | 7 | Label font size |
| InpAlerts | bool | false | Alert once when a closed candle forms a pattern |

Tags: candlestick-patterns, engulfing, pin-bar, hammer, inside-bar, price-action, indicator

Shared code is the author's work, not financial advice. Test on a demo account first.
