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 · MT4 · v1.0 · Free
About Trap Bar Detector
Trap Bar Detector is an indicator for MetaTrader 4. 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.mq4, TrapBarDetector.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Range bars | 20 | Bars of prior range (excludes the signal bar itself) |
| Volume multiple | 1.5 | Signal bar tick volume must exceed this multiple of the average |
| Alerts | true | Alert once per closed bar on a new trap bar |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Breakout · Price Action · Volume · Buy/Sell Arrows · Alerts · MT4 Indicator · MQL4 Source Code