Loading…

Trap Bar Detector

A "trap bar" is a bar whose high or low breaks a recent range, drawing in breakout traders, but which then closes back inside that same range - the breakout fails. On its own, a bar that pokes out and closes back in is a weak signal: it happens constantly on quiet, choppy price action and means very little. What separates a real trap from ordinary noise is volume - a failed breakout on a tick-volume spike is consistent with a genuine stop-run that then reversed against the traders who chased it, while the same shape on quiet volume is just an unremarkable wick. This indicator requires both conditions together: the bar's high (or low) must exceed the highest high (or lowest low) of the prior InpRangeBars bars, the bar must close back inside that prior range, AND its tick volume must be at least InpVolumeMultiple times the average tick volume of those same prior bars. A bull trap (failed break above the range) is marked as a bearish signal; a bear trap (failed break below the range) is marked as bullish - the naming follows which side of traders got trapped, not the direction of the resulting signal. MQL4 forex feeds carry tick volume (number of price changes), not real traded volume - there is no true traded volume on either platform for forex. The volume filter is judged against each symbol's own recent tick-count baseline, which makes it a relative filter, not an absolute threshold comparable across symbols. Notes and limitations Tick volume is a count of price changes, not traded size - treat the volume filter as "unusually active for this symbol recently," not as genuine order-flow confirmation. The range test uses the prior InpRangeBars bars' extremes exactly, so a symbol with a strong pre-existing trend will rarely produce a trap (the range keeps expanding in one direction rather than holding still). This is a pattern marker only; it does not manage a trade or size a stop.

Indicator · MT5 · v1.0 · Free

About Trap Bar Detector

Trap Bar Detector is an indicator for MetaTrader 5. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Range bars, Volume multiple and Alerts. MQL source code included.

Files in the download: TrapBarDetector.ex5, TrapBarDetector.mq5, TrapBarDetector.txt.

Settings

SettingDefaultWhat it does
Range bars20Bars of prior range (excludes the signal bar itself)
Volume multiple1.5Signal bar tick volume must exceed this multiple of the average
AlertstrueAlert once per closed bar on a new trap bar

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Breakout · Price Action · Volume · Buy/Sell Arrows · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria