Swing Failure Pattern
A swing failure pattern here means one specific thing: a bar's wick breaches the most recently confirmed swing high or swing low by at least a minimum distance, and that same bar's close lands back on the near side of the level. Some published versions of this pattern accept the breach on one bar and the close-back on a later bar; this one does not. The wick and the rejection close have to happen on the same bar, or nothing is marked. That is a narrower net - fewer signals - traded deliberately for a stricter, less ambiguous definition. The level being tested is always the single nearest confirmed swing on that side, not every historical swing on the chart. A swing only becomes eligible once it has held for the configured number of bars on both sides. Once a level is swept and fails (the pattern this indicator marks), it is retired - a fresh confirmed swing is needed before that side can fire again. If a bar instead closes cleanly beyond a level rather than rejecting back inside it, that level is also retired, because a clean break is a real move through structure, not a failure, and is no longer a meaningful level to test against. A minimum penetration distance, in pips, keeps a level from being retired by a fractional-point wick that barely pokes past it - broker noise, not a genuine test of the level. Notes and limitations - The wick and the rejection close must be the same bar. A breach on one bar followed by a close-back on a later bar is not marked by this indicator - that is a deliberate design choice, not an oversight. - Only the nearest confirmed swing on each side is tracked; older swings further away are not considered once a newer one has confirmed. - A level is retired the first time it is either swept-and-failed (marked) or cleanly broken (not marked) - either way, the next signal on that side needs a fresh confirmed swing first. - Because the reference swing itself needs InpSwingLookback bars either side to confirm, and the failure test itself only completes on the failure bar's own close, this is a record of a completed event, not a live warning issued while the bar is still forming.
Indicator · MT4 · v1.0 · Free
About Swing Failure Pattern
Swing Failure Pattern 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 4 settings, such as Swing lookback, Min penetration pips and Show level line. MQL source code included.
Files in the download: SwingFailure.ex4, SwingFailure.mq4, SwingFailure.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Swing lookback | 3 | Bars each side required to confirm the swing (K) |
| Min penetration pips | 0.5 | Minimum intrabar breach past the level, in pips |
| Show level line | true | Draw a short segment at the swept level |
| Alerts | true | Alert once, on the SFP bar's close |
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: Buy/Sell Arrows · Alerts · MT4 Indicator · MQL4 Source Code