Candlestick Patterns Indicator: Pin Bars and Inside Bars

Written by Dominic Walsh · Published · Last updated

The candlestick patterns indicator concentrates on two formations rather than a dozen. Pin bars, where a long wick rejects a level, and inside bars that appear after a directional run. Both tests work on proportions and both check what came before, so the arrows describe a pattern in context rather than a shape in isolation.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 2: Pattern Buy, Pattern Sell
Alerts popup, push notification, email, sound
Inputs 10

What the Candlestick Patterns Indicator draws on the chart

Pattern Buy places a lime arrow beneath a bullish pin bar or a qualifying inside bar.

Pattern Sell places a red arrow above the bearish equivalents.

Both pattern types share the same two buffers, so an arrow tells you the direction without naming which formation triggered it.

No lines, boxes or labels are drawn.

  • Pattern Buy: arrow, lime, width 2, arrow code 233
  • Pattern Sell: arrow, red, width 2, arrow code 234
Candlestick patterns indicator on EURUSD H1 marking pin bars and inside bars
Candlestick patterns indicator on EURUSD H1 marking pin bars and inside bars

How the Candlestick Patterns Indicator calculates its values

Measuring the candle

Four values do the work. range is hi[i] – lo[i] and body is the absolute distance between open and close. bodyTop and bodyBot take the higher and lower of the two. From those the code derives lowerWick as bodyBot – lo[i] and upperWick as hi[i] – bodyTop. Every pattern test reads these rather than raw prices.

The pin bar rule

IsBullishPinBar wants a long lower wick and a small body. `WickToBodyRatio` sets how many times the body that wick must reach, and `SmallBodyFraction` caps the body as a share of the full range. Both conditions must hold, which rules out a long candle that happens to have a tail.

The inside bar rule

IsInsideBar checks that the current bar’s range sits entirely inside the previous one. On its own that is common and uninformative, so the code pairs it with context: buyInside also needs IsDowntrendBefore over `TrendLookback` bars, and sellInside needs IsUptrendBefore. An inside bar after a move in the opposite direction is the compression the pattern describes. Arrows land `ArrowOffsetPoints` clear of the candle.

How to read the signals

Both formations share one arrow colour, so check the candle itself to see which fired.

A pin bar at an obvious level means more than the same shape mid-range. The tool does not weigh location.

Inside bar arrows always follow a run, because the trend test is part of the condition.

Frequent arrows on a fast chart usually mean the body fraction is too permissive for that timeframe.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Four channels are available beneath `EnableAlerts`: popup, push notification, email and sound, with `SoundFile` set to `”alert.wav”`. Popup ships enabled and the rest disabled. The code checks time[1] against its stored bar, so a pattern is announced once its bar has closed.

Every Candlestick Patterns Indicator input

Core settings

Setting What it does Default
WickToBodyRatio Pin Bar: long wick must exceed this multiple of body. How many times the body the rejection wick must reach, default `2.0`. Raise it to 3.0 for longer, more decisive tails. 2.0
SmallBodyFraction Pin Bar: body must be < this fraction of full range. Largest body allowed as a share of the candle’s range, default `0.34`. Lower it to insist on a smaller body. 0.34
TrendLookback Inside Bar: trend lookback (bars). Bars checked for a prior move before an inside bar counts, default `5`. 5

Display settings

Setting What it does Default
ArrowOffsetPoints Arrow vertical offset in points. Distance between candle and arrow, default `12` points. 12

Alert settings

Setting What it does Default
EnableAlerts (see inputs panel) on
EnablePopup (see inputs panel) on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile (see inputs panel) alert.wav
Candlestick patterns indicator inputs: WickToBodyRatio, SmallBodyFraction, TrendLookback
Candlestick patterns indicator inputs: WickToBodyRatio, SmallBodyFraction, TrendLookback

Settings that fit your chart

Pin bars need a real range to reject into, so H1 and above read best. EURUSD H1 is the reference chart. On M1 and M5 the spread often rivals the body and the ratio tests trigger on candles that mean nothing. On H4 and daily both formations become rarer and each one covers more ground, which suits traders who check charts a few times a day.

When the Candlestick Patterns Indicator fails

A pin bar is only meaningful where it forms. This build tests shape and, for inside bars, the preceding move, but never whether the candle sits at a level anyone was watching.

A five bar lookback is a low bar for calling a trend, so some inside bar arrows follow a drift rather than a move.

Ratio thresholds create hard edges: a body at 0.34 of range passes and 0.35 fails, though the two candles look identical.

Copy the compiled Candlestick Patterns Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the Candlestick Patterns Indicator for MT4 and MT5

The zip holds the compiled Candlestick Patterns Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Which two patterns does this build actually detect?

Pin bars and inside bars, in both directions. Pin bars use `WickToBodyRatio` and `SmallBodyFraction`. Inside bars use IsInsideBar paired with a trend check over `TrendLookback` bars. Both write to the same Pattern Buy and Pattern Sell buffers, so the arrow shows direction rather than which formation triggered.

What does SmallBodyFraction at 0.34 mean?

The body may occupy at most 34% of the candle’s high-to-low range. Combined with the wick rule, that forces the classic pin bar shape: a small body at one end and a long tail at the other. Lowering it toward 0.25 gives stricter pins and noticeably fewer of them.

Why does an inside bar also need the TrendLookback check?

Because an inside bar alone is just a quiet candle, and quiet candles are everywhere. Requiring IsDowntrendBefore or IsUptrendBefore over `TrendLookback` bars means the compression follows a directional move, which is the setup traders actually watch for. Without it the chart fills with meaningless arrows.

Should I raise WickToBodyRatio above 2.0?

Try it if the pins look weak. At `2.0` the wick must be twice the body, which is the common definition. At 3.0 you get fewer arrows and each candle shows a more decisive rejection. The right value depends on the instrument, so compare a few settings on your own EURUSD H1 chart before settling.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Candlestick Patterns Indicator as one input. Always backtest before trading live.

Category: this is part of our Candle Sticks collection. Also, truly, browse more Candle Sticks for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment