OPEN-SOURCE SCRIPT

Structural Momentum Bias [JOAT]

2 544

Structural Momentum Bias [JOAT]

Introduction

Structural Momentum Bias is an overlay indicator that combines pivot-based market structure classification with a double-smoothed momentum band system to identify the current market regime and its directional bias. The indicator continuously tracks swing highs and lows, classifies them as higher highs, lower highs, higher lows, or lower lows, and scores momentum strength on a 0-5 scale using band position and structure alignment. A break-of-structure detection system marks confirmed liquidity shifts in real time.

The core problem this indicator addresses is the disconnect between price structure and momentum. Many traders either follow structure without measuring momentum strength, or use oscillators without understanding what market structure those signals occur within. This indicator unifies both, producing a regime label (Bullish, Bearish, or Ranging) backed by a quantified score. A regime classification without a corresponding score is ambiguous. A score without regime context is incomplete. Together they provide a clearer picture of where the market is and how strongly it is in that state.

snapshot
Core Concepts

1. Double-Smoothed Baseline (SMEMA)

The baseline uses a two-pass smoothing method: an EMA applied to price, followed by an SMA applied to that EMA. This reduces noise while maintaining responsiveness. It outperforms a simple MA in choppy markets because the double-pass eliminates high-frequency oscillations that cause false regime flips. The baseline slope (rising or falling) is one input into the regime classification.

2. Dynamic Step Channel

The channel bands are not fixed multiples of ATR. Instead, they use the 100-bar average of the high-low range as the step unit, producing three tiers of bands above and below the baseline. This approach adapts to each instrument's natural swing amplitude without requiring manual calibration per market. Each band tier has a gradient color that intensifies as price approaches that level from within the channel, providing visual distance context.

3. Pivot-Based Structure Classification

Swing highs and lows are identified using confirmed pivots (lookback left and right bars). The indicator classifies the relationship between successive pivots as HH (higher high), LH (lower high), HL (higher low), or LL (lower low). These four states are combined to determine whether structure is bullish (HH + HL), bearish (LH + LL), or mixed. Importantly, pivot detection is offset by the lookback period, so no repainting occurs — a pivot is only confirmed when enough subsequent bars have closed to validate it.

4. Momentum Strength Score (0-5)

The score adds one point for each of: price above band tier 1, price above band tier 2, price above band tier 3, higher high present, and higher low present (inverted for bearish scoring). This produces a 0-5 integer that quantifies how strongly the market is expressing the current regime. A score of 5 in a bullish regime means price is extended above all three band tiers with confirmed higher highs and higher lows — a strongly trending condition. A score of 1 or 2 suggests marginal or weakening conditions.

5. Break of Structure (BOS) Detection

A bullish BOS is confirmed when price closes above the most recent swing high on a confirmed bar. A bearish BOS is confirmed when price closes below the most recent swing low. The BOS line is drawn from the pivot bar to the current bar and extends right, with a thick transparent shadow line providing visual depth. BOS detection only fires on barstate.isconfirmed, preventing any repainting.

Features

  • Regime Dashboard: 9-row dark-themed table showing regime, baseline direction, bull score, bear score, structure state, ATR, and last BOS
  • Dynamic Momentum Bands: Six gradient-colored bands (three above, three below) that visually represent price position within the momentum channel
  • SMEMA Baseline: Color-coded by regime, changes in real time as regime shifts
  • Break of Structure Lines: Thin solid + thick ghost dual-line rendering at confirmed structural breaks, extending to the current bar
  • Confirmed Pivot Dots: Small circles at each confirmed swing high and low, plotted at the exact pivot bar
  • Bar Coloring: Candles are colored by current regime state
  • Band Fill Gradients: Fill between band tiers intensifies based on price proximity


Input Parameters

Structure Settings:
  • Pivot Lookback: Number of bars left and right required to confirm a pivot (default: 5)
  • Baseline Length: Period for the SMEMA double-smoothed baseline (default: 10)
  • Show Structure Breaks: Toggle BOS line rendering


Visual Settings:
  • Dashboard toggle and position
  • Momentum Bands toggle
  • Bullish, Bearish, and Ranging color inputs


How to Use This Indicator

Step 1: Read the Regime
The dashboard label and bar coloring immediately show the current regime. Bullish requires the baseline to be rising and a momentum score of 2 or more.

Step 2: Assess Score Strength
A score of 4-5 indicates a well-developed trend with band extension and confirmed structure. A score of 1-2 suggests the regime is marginal and may not sustain.

Step 3: Watch for BOS Events
A BOS in the direction of the regime adds confirmation that a structural shift has occurred. A counter-regime BOS is an early warning that conditions may be changing.

Step 4: Use Bands for Context
Price returning to the baseline from above in a bullish regime is a potential pullback entry area. Price extending above band tier 2 or 3 suggests overextension.

Limitations

  • The pivot confirmation delay (lookback bars) means BOS signals and pivot markers appear several bars after the actual swing point. This is a deliberate design choice to prevent repainting
  • The regime score of 2 as the minimum threshold for classification means borderline conditions will oscillate between Ranging and a directional regime on consecutive bars
  • The SMEMA baseline is smoother than a standard EMA but still lags price. In fast-moving markets this lag may cause regime flips after significant portions of a move have already occurred
  • Band width is determined by the 100-bar average of bar ranges. In markets with sudden volatility regime changes (such as after news releases), the bands may not reflect the new volatility environment for many bars


Originality Statement

This indicator is original in its specific combination of elements and the scoring framework it produces. The justification for combining structure detection with a band-based scoring system is that neither component alone provides actionable context. Structure alone (HH/HL) says direction but not strength. Bands alone say relative position but not structural validity. The 0-5 score synthesizes both into a single conviction metric. The double-smoothed baseline (EMA of EMA, then SMA) is a deliberate design choice that reduces false regime flips without the extreme lag of longer single-pass averages. The dynamic step channel uses bar range (not ATR) as its unit, which scales naturally with each instrument's price action characteristics.

Disclaimer

This indicator is provided for educational and informational purposes only. It does not constitute financial advice or a recommendation to buy or sell any financial instrument. Past structural patterns do not guarantee their repetition. A bullish regime classification does not predict future price direction. Always apply proper risk management. The author is not responsible for any trading losses.

-Made with passion by officialjackofalltrades

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.