Occurrence Scanner | MA Resilience & Breakout LogicThis indicator is designed to quantify the reliability of a Moving Average (MA) as a dynamic Support or Resistance level. Unlike standard crossover indicators that generate signals on every touch, this script employs a rigorous "Zone Tolerance" and "Temporal Confirmation" logic to filter out noise and classify price action into three distinct behaviors: Valid Bounce, Confirmed Breakout, or False Breakout (Trap).
It also integrates an optional Volatility Filter (based on TTM Squeeze mechanics) to prevent false signals during low-volatility "chop" regimes.
HOW IT WORKS:
1. The "Safe Zone" (Buffer Logic): Standard MAs are thin lines. This script creates a programmable "Road" around the MA (defined by the Zone Tolerance % input).
A touch is only considered a potential breakout if the price closes outside this zone.
Wicks that pierce the MA but close inside the zone are treated as Bounces (respecting the level).
2. Event Classification (The Decision Engine): Once the price interacts with the MA Zone, a "Sovereignty Window" (Lookahead Timer) is activated to monitor the subsequent candles:
✅ Bounce: Price tests the MA but never closes outside the Safe Zone during the window. The MA held as support/resistance.
❌ Breakout (Breakdown/Breakup): Price closes outside the Safe Zone. A strict "2-Consecutive Close" logic is applied to confirm the trend change immediately, avoiding premature signals.
⚠️ False Break: Price momentarily closes outside the zone but aggressively reverses to the opposite side within the time window. This identifies "Bull/Bear Traps".
3. The Volatility Filter (Anti-Chop): Market consolidation often leads to MA whipsaws.
The script calculates Bollinger Bands (2.0 std) vs. Keltner Channels (1.5 ATR).
If the Squeeze Filter is enabled in settings, the script forces the scanner to IGNORE any MA touches while volatility is compressed (Squeeze ON). This ensures signals are only generated during active trends.
SETTINGS:
MA Type & Length: Choose between SMA or EMA and the period (e.g., 20, 50, 200).
Zone Tolerance (+/- %): The buffer width. Default is 0.2%. Higher values filter more noise.
Lookahead Candles: The confirmation window size.
Squeeze Filter: Toggle On/Off to ignore signals during low volatility regimes.
INTENDED USE: This tool is intended for Swing Traders and Scalpers looking to statistically validate which Moving Average is being respected by a specific asset. It automates the "visual backtest" process, providing a Dashboard with success rates for Bounces vs. Breaks.
Wskaźnik Pine Script®






















