What this TradingView script does
Market Structure Oscillator is a dual-purpose tool that tracks market structure breaks (CHoCH & BoS) on the price chart while calculating a trend-filtered momentum oscillator in a separate pane. It solves the problem of conflicting signals by forcing the momentum oscillator to align with the structural trend—keeping momentum values strictly above 50 during an uptrend and below 50 during a downtrend.
🔵 HOW IT WORKS The indicator combines a market structure state machine with a customized momentum engine and a divergence scanner:
1 — Market Structure Engine
- Pivot & Break Detection: Uses Market Structure Pivot Left/Right to identify structural swing highs and lows, triggering a trend shift when price closes beyond them.
- CHoCH & BoS Labels: The first break in a new direction is labeled "CHoCH" (Change of Character), while subsequent breaks in the same direction are labeled "BoS" (Break of Structure).
- Swing Counts: Tracks and labels the numerical count of consecutive breaks to help gauge trend extension.
2 — Filtered Momentum Oscillator
- Raw Momentum: Calculates the rate of change divided by price volatility over the Custom Momentum Length.
- Sigmoid Smoothing: Applies a sigmoid function to map momentum to a 0–100 scale, then smooths it with an EMA based on the Smoothing Length.
- Trend Filtering: The oscillator is forced to stay above 50 during confirmed bullish structure and below 50 during bearish structure, eliminating contradictory readings.
How traders can use it
Use Market Structure Oscillator as a chart context layer inside TradingView: read the structure it highlights, compare it with your market bias, and let the script narrow which moves deserve attention.
The strongest workflow is to combine the script with higher timeframe structure, volume context, and a repeatable execution plan instead of treating any single label as a standalone trade.




