Eye Pattern Failure Trap [EyeAlgo]

Eye Pattern Failure Trap marks the moment a chart-pattern breakout fails: price closes outside a Range Box, Double Top/Bottom, Triangle or Inside Bar, then closes back inside within a few bars. That failed breakout prints a trap signal in the opposite direction, and a Failure Funnel beside the last candle counts how often breakouts have failed on your symbol.

🟢 THE IDEA
Breakout traders buy the close above a pattern or sell the close below it. When price comes straight back inside, those traders are now on the wrong side. Eye Pattern Failure Trap is built around that event and answers three questions:
▶ Which pattern just failed, and in which direction is the trap?
▶ Where would a fade of that failure be wrong (stop), and where is the other side of the pattern (target)?
▶ On this symbol and timeframe, how often have breakouts from each pattern type failed so far?
🟢 WHAT THIS PUBLICATION ADDS
▶ Four pattern types tracked side by side with the same breakout and failure rules: Range Box, Double Top / Double Bottom, Triangle (ascending, descending, symmetrical) and Inside Bar.
▶ A separate failure rate for each pattern type, plus one overall rate for the symbol, counted live from the chart history.
▶ Failure Funnel drawn next to the last candle: breakouts at the top, failed breakouts in the middle, traps that reached the target at the bottom.
▶ Failed Pattern List under the funnel: the latest traps with direction, ⭐ grade, pattern name, age in bars and result (✔ Target / ✖ Stop / ⌛ Time-out / ⏳ Open).
▶ ⭐ grade on every trap, built from how hard price snapped back, how fast the breakout failed, and whether that pattern type fails often on this chart.
▶ Trade plan lines for each trap label: entry, stop beyond the trap extreme, target at the opposite side of the pattern.
▶ Own calculation from start to end; no other script's code or formula is used.
🟢 HOW A TRAP IS FOUND
1. Patterns
Range Box: the last 20 bars stayed inside 3 ATR (and at least 0.5 ATR tall). Double Top / Bottom: two swing highs (or lows) within 0.5 ATR of each other, at least 1 ATR from the neckline between them, within the last 300 bars. Triangle: the last two swing highs and two swing lows form converging lines, at least 0.5 ATR wide now, within the last 300 bars. Inside Bar: a bar fully inside a mother bar of at least 1 ATR. Patterns appear grey and dashed while they wait.
2. Breakout
A bar must CLOSE beyond the pattern edge by the breakout buffer (0.10 ATR by default). Wicks alone do not count. A pattern with no breakout expires after 40 bars (Inside Bar after 12).
3. Failure = trap
If, within the failure window (5 bars), a bar closes back inside the broken edge, the breakout is marked FAILED. The pattern turns red (failed upside = ▼ BULL TRAP) or green (failed downside = ▲ BEAR TRAP) and a label prints on that bar. If no close comes back inside within the window, the breakout counts as held.
4. Grade
One ⭐ for each: the failure close is at least 0.3 ATR back inside the edge; the breakout failed within 2 bars; this pattern type had already failed on 50% or more of at least 5 earlier breakouts on this chart. A trap with none of these shows "–".
5. Trade plan and result
Entry = close of the failure bar. Stop = the highest high (bull trap) or lowest low (bear trap) since the breakout, plus 0.10 ATR. Target = the opposite edge of the pattern, but never closer than 1R. Each trap is then followed bar by bar, from the next bar, until stop, target or the 60-bar time-out. If stop and target are both touched on the same bar, it is counted as a stop.
🟢 READING THE FAILURE FUNNEL
▶ Top (grey) — BREAKOUTS: every pattern breakout that has been decided (failed or held).
▶ Middle (red) — FAILED: breakouts that came back inside, with the failure %.
▶ Bottom (green) — target: traps that reached their target.
▶ Under the funnel: "Trap → target %" = target hits ÷ (target hits + stops); the "closed" count in brackets is target hits + stops, so time-outs and open traps are left out. Then the pattern type with the highest failure %, the failure % of every pattern type, and the Failed Pattern List.

🟢 WHAT THE NUMBERS SHOWED
Default settings on OANDA:XAUUSD 30m, all history the chart loaded (checked 3 Nov 2026):
▶ Breakouts decided: 2038 — failed: 1053 (52%)
▶ Failure % by pattern: Range Box 46%, Double Top/Bottom 48%, Triangle 52%, Inside Bar 54%
▶ Trap → target: 39% (407 targets out of 1037 pattern-traps that reached target or stop; overlapping patterns are counted separately)
▶ Same check on NSE:NIFTY 30m: 1003 breakouts, 445 failed (44%), trap → target 48% (436 traps)
How to read this: about half of the close-confirmed breakouts on this chart came back inside within 5 bars. A 39% target rate says nothing about profit on its own: reward-to-risk is different for every trap (minimum 1R), time-outs are left out, and spread, commission and slippage are not included. These numbers are in-sample, measured on chart history with the default settings, and are not a performance expectation. They change with symbol, timeframe and settings, so test the parameters and timeframe on your own instrument.
🟢 HOW TO USE
1. Add the indicator and look at the funnel first. A high failure % tells you that chasing breakouts on this chart has often been caught on the wrong side.
2. Wait for a ▼ BULL TRAP or ▲ BEAR TRAP label. It only prints after the failure bar has closed.
3. Check the ⭐ grade and whether this pattern type has a high failure % in the funnel line.
4. Use the dotted entry, red stop and green target lines as a reference for your own plan, not as orders.
5. Follow the Failed Pattern List to see how the recent traps on this chart ended.
🟢 SETTINGS GUIDE
Open the indicator settings (gear icon).
Quick guide:
▶ Fewer traps: raise "Breakout buffer (ATR)" or lower "Failure window (bars)".
▶ Only the patterns you trade: switch off "Range Box", "Double Top / Bottom", "Triangle (ascending / descending / symmetrical)" or "Inside Bar".
▶ Wider or tighter range boxes: change "Range Box max height (ATR)" and the bars next to "Range Box".
▶ Bigger swings for doubles and triangles: raise "Swing length (Double / Triangle)".
▶ Funnel too close or too big: change "Funnel distance from last bar (bars)" and "Funnel height (ATR scale)".
▶ Patterns watched — Range Box + bars, Range Box max height (ATR), Double Top / Bottom + tolerance (ATR), Triangle (ascending / descending / symmetrical), Inside Bar + min mother bar (ATR), Swing length (Double / Triangle).
▶ Breakout & trap rules — Breakout buffer (ATR), Failure window (bars), Pattern expires after (bars), Stop beyond trap extreme (ATR), Minimum target (R), Trap trade time-out (bars).
▶ Display — Show breakouts that held, Show trade plan (entry / stop / target), Traps kept on chart, Show failure funnel, Funnel distance from last bar (bars), Funnel height (ATR scale), Funnel text size, Failed patterns listed, Bear trap (buy) colour, Bull trap (sell) colour, Pattern colour.
🟢 ALERTS
▶ Bull Trap (sell) — a failed upside breakout
▶ Bear Trap (buy) — a failed downside breakout
▶ Any trap
▶ Detailed alert: choose "Any alert() function call" to get the symbol, trap type, pattern name, entry, stop and target in the message.
All alerts fire once on bar close.
🟢 LIMITS
▶ Traps, labels, results and alerts are decided on closed bars and do not repaint. The funnel and list are redrawn on the live bar but only count closed bars.
▶ Swings for Double Top/Bottom and Triangle are confirmed "Swing length" bars after the swing, so those patterns appear with that delay.
▶ The same breakout can fail out of more than one pattern at once; each pattern is counted on its own, so the rows overlap and one price move can count as more than one trap in the target statistics.
▶ All percentages and the third ⭐ depend on how much history your chart loads and on the settings.
▶ Only one pattern of each type (up to three for Double) is watched at a time, so not every possible pattern is drawn.
▶ TradingView allows 500 boxes, lines and labels per script; the oldest traps are removed ("Traps kept on chart").
▶ The script does not place trades.
🟢 DISCLAIMER
This script is for educational and informational purposes only and is not financial advice. Past behaviour of any indicator does not guarantee future results. Always use your own analysis and risk management.
🟢 THE IDEA
Breakout traders buy the close above a pattern or sell the close below it. When price comes straight back inside, those traders are now on the wrong side. Eye Pattern Failure Trap is built around that event and answers three questions:
▶ Which pattern just failed, and in which direction is the trap?
▶ Where would a fade of that failure be wrong (stop), and where is the other side of the pattern (target)?
▶ On this symbol and timeframe, how often have breakouts from each pattern type failed so far?
🟢 WHAT THIS PUBLICATION ADDS
▶ Four pattern types tracked side by side with the same breakout and failure rules: Range Box, Double Top / Double Bottom, Triangle (ascending, descending, symmetrical) and Inside Bar.
▶ A separate failure rate for each pattern type, plus one overall rate for the symbol, counted live from the chart history.
▶ Failure Funnel drawn next to the last candle: breakouts at the top, failed breakouts in the middle, traps that reached the target at the bottom.
▶ Failed Pattern List under the funnel: the latest traps with direction, ⭐ grade, pattern name, age in bars and result (✔ Target / ✖ Stop / ⌛ Time-out / ⏳ Open).
▶ ⭐ grade on every trap, built from how hard price snapped back, how fast the breakout failed, and whether that pattern type fails often on this chart.
▶ Trade plan lines for each trap label: entry, stop beyond the trap extreme, target at the opposite side of the pattern.
▶ Own calculation from start to end; no other script's code or formula is used.
🟢 HOW A TRAP IS FOUND
1. Patterns
Range Box: the last 20 bars stayed inside 3 ATR (and at least 0.5 ATR tall). Double Top / Bottom: two swing highs (or lows) within 0.5 ATR of each other, at least 1 ATR from the neckline between them, within the last 300 bars. Triangle: the last two swing highs and two swing lows form converging lines, at least 0.5 ATR wide now, within the last 300 bars. Inside Bar: a bar fully inside a mother bar of at least 1 ATR. Patterns appear grey and dashed while they wait.
2. Breakout
A bar must CLOSE beyond the pattern edge by the breakout buffer (0.10 ATR by default). Wicks alone do not count. A pattern with no breakout expires after 40 bars (Inside Bar after 12).
3. Failure = trap
If, within the failure window (5 bars), a bar closes back inside the broken edge, the breakout is marked FAILED. The pattern turns red (failed upside = ▼ BULL TRAP) or green (failed downside = ▲ BEAR TRAP) and a label prints on that bar. If no close comes back inside within the window, the breakout counts as held.
4. Grade
One ⭐ for each: the failure close is at least 0.3 ATR back inside the edge; the breakout failed within 2 bars; this pattern type had already failed on 50% or more of at least 5 earlier breakouts on this chart. A trap with none of these shows "–".
5. Trade plan and result
Entry = close of the failure bar. Stop = the highest high (bull trap) or lowest low (bear trap) since the breakout, plus 0.10 ATR. Target = the opposite edge of the pattern, but never closer than 1R. Each trap is then followed bar by bar, from the next bar, until stop, target or the 60-bar time-out. If stop and target are both touched on the same bar, it is counted as a stop.
🟢 READING THE FAILURE FUNNEL
▶ Top (grey) — BREAKOUTS: every pattern breakout that has been decided (failed or held).
▶ Middle (red) — FAILED: breakouts that came back inside, with the failure %.
▶ Bottom (green) — target: traps that reached their target.
▶ Under the funnel: "Trap → target %" = target hits ÷ (target hits + stops); the "closed" count in brackets is target hits + stops, so time-outs and open traps are left out. Then the pattern type with the highest failure %, the failure % of every pattern type, and the Failed Pattern List.
🟢 WHAT THE NUMBERS SHOWED
Default settings on OANDA:XAUUSD 30m, all history the chart loaded (checked 3 Nov 2026):
▶ Breakouts decided: 2038 — failed: 1053 (52%)
▶ Failure % by pattern: Range Box 46%, Double Top/Bottom 48%, Triangle 52%, Inside Bar 54%
▶ Trap → target: 39% (407 targets out of 1037 pattern-traps that reached target or stop; overlapping patterns are counted separately)
▶ Same check on NSE:NIFTY 30m: 1003 breakouts, 445 failed (44%), trap → target 48% (436 traps)
How to read this: about half of the close-confirmed breakouts on this chart came back inside within 5 bars. A 39% target rate says nothing about profit on its own: reward-to-risk is different for every trap (minimum 1R), time-outs are left out, and spread, commission and slippage are not included. These numbers are in-sample, measured on chart history with the default settings, and are not a performance expectation. They change with symbol, timeframe and settings, so test the parameters and timeframe on your own instrument.
🟢 HOW TO USE
1. Add the indicator and look at the funnel first. A high failure % tells you that chasing breakouts on this chart has often been caught on the wrong side.
2. Wait for a ▼ BULL TRAP or ▲ BEAR TRAP label. It only prints after the failure bar has closed.
3. Check the ⭐ grade and whether this pattern type has a high failure % in the funnel line.
4. Use the dotted entry, red stop and green target lines as a reference for your own plan, not as orders.
5. Follow the Failed Pattern List to see how the recent traps on this chart ended.
🟢 SETTINGS GUIDE
Open the indicator settings (gear icon).
Quick guide:
▶ Fewer traps: raise "Breakout buffer (ATR)" or lower "Failure window (bars)".
▶ Only the patterns you trade: switch off "Range Box", "Double Top / Bottom", "Triangle (ascending / descending / symmetrical)" or "Inside Bar".
▶ Wider or tighter range boxes: change "Range Box max height (ATR)" and the bars next to "Range Box".
▶ Bigger swings for doubles and triangles: raise "Swing length (Double / Triangle)".
▶ Funnel too close or too big: change "Funnel distance from last bar (bars)" and "Funnel height (ATR scale)".
▶ Patterns watched — Range Box + bars, Range Box max height (ATR), Double Top / Bottom + tolerance (ATR), Triangle (ascending / descending / symmetrical), Inside Bar + min mother bar (ATR), Swing length (Double / Triangle).
▶ Breakout & trap rules — Breakout buffer (ATR), Failure window (bars), Pattern expires after (bars), Stop beyond trap extreme (ATR), Minimum target (R), Trap trade time-out (bars).
▶ Display — Show breakouts that held, Show trade plan (entry / stop / target), Traps kept on chart, Show failure funnel, Funnel distance from last bar (bars), Funnel height (ATR scale), Funnel text size, Failed patterns listed, Bear trap (buy) colour, Bull trap (sell) colour, Pattern colour.
🟢 ALERTS
▶ Bull Trap (sell) — a failed upside breakout
▶ Bear Trap (buy) — a failed downside breakout
▶ Any trap
▶ Detailed alert: choose "Any alert() function call" to get the symbol, trap type, pattern name, entry, stop and target in the message.
All alerts fire once on bar close.
🟢 LIMITS
▶ Traps, labels, results and alerts are decided on closed bars and do not repaint. The funnel and list are redrawn on the live bar but only count closed bars.
▶ Swings for Double Top/Bottom and Triangle are confirmed "Swing length" bars after the swing, so those patterns appear with that delay.
▶ The same breakout can fail out of more than one pattern at once; each pattern is counted on its own, so the rows overlap and one price move can count as more than one trap in the target statistics.
▶ All percentages and the third ⭐ depend on how much history your chart loads and on the settings.
▶ Only one pattern of each type (up to three for Double) is watched at a time, so not every possible pattern is drawn.
▶ TradingView allows 500 boxes, lines and labels per script; the oldest traps are removed ("Traps kept on chart").
▶ The script does not place trades.
🟢 DISCLAIMER
This script is for educational and informational purposes only and is not financial advice. Past behaviour of any indicator does not guarantee future results. Always use your own analysis and risk management.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.