Skip to main content

Module sr_monitor

Module sr_monitor 

Source
Expand description

S/R Interaction Monitoring System (MQL5 Part 67)

Real-time horizontal Support/Resistance level monitoring with interaction detection (Approach, Touch, Breakout, Reversal, Retest). Built directly on the shared Swing + MarketStructure foundation (Part 21 / quantwave-iuzv).

Sources (recorded verbatim per project rules):

  • Primary: https://www.mql5.com/en/articles/21961 “Price Action Analysis Toolkit Development (Part 67): Automating Support and Resistance Monitoring in MQL5” by Christian Benjamin (lynnchris). Published ~2026-04-30.
  • Archived authoritative source: references/MQL5/lynnchris/implemented/Part67/SupportResistanceMonitor.mq5 (core detection state machine in SMonitoredLine + OnTick logic lines ~382-516; ELineType + tolerance handling, side tracking, approached/touched/breakoutHappened/retest flags).
  • Foundation dependency: quantwave-core/src/indicators/market_structure.rs (iuzv, Part 21 Flip_Detector.mq5) for SwingPoint + confirmed bias/flips used to auto-generate levels.
  • Design lessons (rich events first): closed quantwave-bfg (Part 66), quantwave-r46a (Part 69), quantwave-wtz (MQL5 catalog), and live geometric_patterns.rs (ej8b) precedent: “emit clean rich event structs with metadata first; visualization is secondary.” “Rich output structs are the primary deliverable (for backtester sizing, ML features, confluence).”

QuantWave adaptations (no chart objects, streaming-first):

  • Supports BOTH auto-generated horizontal levels (promoted from confirmed SwingPoints in internal MarketStructure, with de-duplication) AND user-provided levels (dynamic add/remove API for backtester (quantwave-gwx) and notebook consumption).
  • Interaction detection faithful to Part 67 (tolerances, pre-touch side for reversal, breakout direction, retest after breakout flag reset).
  • Primary output: rich SRInteraction events (Vec per step) + passthrough MarketStructureState.
  • Full Next<T> + batch replay parity (mandatory).
  • Property invariants + synthetic generators exercising touch/breakout/retest/reversal paths + noise.

Rich event coordination:

  • Proposes SRInteraction + SRInteractionType + LevelSource (and SRMonitorOutput).
  • Shape chosen for consistency with FlipEvent, FlagPattern, HsPattern (bar, price, strength, *_confirmed style metadata).
  • If/when quantwave-bmkn (in_progress) standardizes a common PA event envelope or adds regime_at_event / atr_at_event / confluence, this can be extended without breaking the streaming contract. Noted in bead update.

Integration: Usable standalone for backtester event streams or composed (like GeometricPatternScanner). Polars exposure and canonical notebook usage targeted via 5mfc / 5thj children.

Structs§

SRInteraction
Rich event emitted when an interaction is detected on a monitored level. Primary output for backtester, confluence, and ML feature enrichment.
SRInteractionMonitor
The main streaming S/R Interaction Monitor. Implements the Universal Indicator pattern: owns state, exposes Next, produces rich events.
SRMonitorOutput
Combined output returned on every next() call. Contains the underlying structure state (for composition / downstream MS filters) plus all interactions detected on this bar across all monitored levels (0 or more).

Enums§

LevelSource
Source of a monitored S/R level.
SRInteractionType
The five interaction types detected per Part 67 (approach added for pre-signal utility).

Constants§

SR_INTERACTION_MONITOR_METADATA