Market Structure (Swings + BOS)
Adaptive swing detection with ATR-derived depth + bias tracking and confirmed Break of Structure flips (HH/HL/LL/LH). Foundation for geometric PA patterns (Flags, H&S) and S/R monitoring from the MQL5 lynnchris toolkit (Part 21).
Usage
Use .ta.market_structure() or the Rust struct for rich PA events. Bias and flips feed position sizing, regime filters, and confluence with ML features / Ehlers regimes. Emit as Struct for backtester consumption.
Background
Not Ehlers DSP; classical PA structure from MQL5 series. See Part 21 for ATR-adaptive depth swings and confirmed flips only after bias (avoids premature signals).
Parameters
swing_strength(default: 3): Bar window radius for local extremum (depth). Part 21 derives this from ATR*mult; fixed here for streaming parity + immediate use (see source Flip_Detector.mq5:150).
Formula
\text{depth} = \max(1, \lfloor \text{ATR} \times \text{mult} \times \text{loosen} / \text{point} \rfloor) \text{IsSwingHigh}(shift, depth) = \forall i \in [shift-depth, shift+depth], i \ne shift: High_i \le High_{shift}