OPEN-SOURCE SCRIPT
Market Structure Trend Matrix [BigBeluga]

CTURE TREND MATRIX [BigBeluga]
// ═══════════════════════════════════════════════════════════════════════════════
//
// OVERVIEW
// ────────
// A comprehensive technical analysis framework for traders who demand precision
// in identifying market regimes and trend expansions.
// Combines automated Market Structure (MS) detection with volatility-adjusted
// risk parameters (ATR), providing a systematic roadmap for navigating price action.
//
// ARCHITECTURE & CORE LOGIC
// ──────────────────────────
// • Automated Structure Mapping: A pivot-detection engine (MS Length) that scans
// for institutional-grade swing highs and lows, ignoring retail noise.
// Structural lines are drawn only when significant supply or demand zones are breached.
//
// • ChoCh Engine (Change of Character): When price crosses a recent pivot high or
// low, the indicator prints a "ChoCh ↑ / ↓" label. This represents a fundamental
// shift in market sentiment — the current trend has likely ended and a new cycle begins.
//
// • Infinite Expansion Targets: Sequential levels calculated using ATR multipliers
// that expand and contract with current market volatility. Each time price hits a
// target, the next level is projected automatically.
//
// • Volatility-Anchored Trailing Stop: A dynamic ATR-based stop that acts as a
// "ratchet" mechanism — it moves closer to price during trend expansion but stays
// firm during minor pullbacks, providing a clear exit point if the trend fails.
//
// ADVANCED FEATURES
// ─────────────────
// • Target History Control (Show History): toggle historical target lines and
// percentage labels on/off to keep the chart clean.
// • Dynamic Trailing Stop Visibility (Show Trailing Stop).
// • Percentage profit labels at each target hit, measured from the ChoCh entry.
// • Volatility-adjusted spacing: both the trailing stop and target steps use ATR
// calculations — effective across all asset classes (Crypto, Forex, Equities…).
//
// HOW TO INTERPRET
// ────────────────
// • Bullish State (green): Activated when price breaks above a major Pivot High.
// Projects upward expansion targets and keeps the trailing stop below price.
// → BUY signal printed at the ChoCh ↑
//
// • Bearish State (pink/purple): Activated when price breaks below a major Pivot Low.
// Projects downward targets and keeps the trailing stop above price.
// → SELL signal printed at the ChoCh ↓
//
// • Target Hit: each time a target level is reached, the % gain from the ChoCh
// entry is displayed on the chart.
//
// • Stop Hit: if price crosses the Trailing Stop against the active trend direction,
// an EXIT signal is printed.
//
// RECOMMENDED USAGE
// ─────────────────
// • Scalping / Day Trading → MS Length 5-8, 1m-5m charts.
// • Swing Trading → MS Length 15-20, D1 / H4 charts.
// • Risk-Reward Management → Distance ChoCh ↔ Trailing Stop = objective risk.
// Sequential targets = profit milestones.
//
// SIGNALS INCLUDED IN THIS SCRIPT
// ────────────────────────────────
// [BUY] → Bullish ChoCh confirmed (green arrow below the bar)
// [SELL] → Bearish ChoCh confirmed (pink arrow above the bar)
// [TARGET] → Price reaches a target (label with % gain above/below the bar)
// [EXIT] → Price crosses the Trailing Stop against the trend
// Configurable TradingView alerts available for all 4 events above.
// ═══════════════════════════════════════════════════════════════════════════════
// ═══════════════════════════════════════════════════════════════════════════════
//
// OVERVIEW
// ────────
// A comprehensive technical analysis framework for traders who demand precision
// in identifying market regimes and trend expansions.
// Combines automated Market Structure (MS) detection with volatility-adjusted
// risk parameters (ATR), providing a systematic roadmap for navigating price action.
//
// ARCHITECTURE & CORE LOGIC
// ──────────────────────────
// • Automated Structure Mapping: A pivot-detection engine (MS Length) that scans
// for institutional-grade swing highs and lows, ignoring retail noise.
// Structural lines are drawn only when significant supply or demand zones are breached.
//
// • ChoCh Engine (Change of Character): When price crosses a recent pivot high or
// low, the indicator prints a "ChoCh ↑ / ↓" label. This represents a fundamental
// shift in market sentiment — the current trend has likely ended and a new cycle begins.
//
// • Infinite Expansion Targets: Sequential levels calculated using ATR multipliers
// that expand and contract with current market volatility. Each time price hits a
// target, the next level is projected automatically.
//
// • Volatility-Anchored Trailing Stop: A dynamic ATR-based stop that acts as a
// "ratchet" mechanism — it moves closer to price during trend expansion but stays
// firm during minor pullbacks, providing a clear exit point if the trend fails.
//
// ADVANCED FEATURES
// ─────────────────
// • Target History Control (Show History): toggle historical target lines and
// percentage labels on/off to keep the chart clean.
// • Dynamic Trailing Stop Visibility (Show Trailing Stop).
// • Percentage profit labels at each target hit, measured from the ChoCh entry.
// • Volatility-adjusted spacing: both the trailing stop and target steps use ATR
// calculations — effective across all asset classes (Crypto, Forex, Equities…).
//
// HOW TO INTERPRET
// ────────────────
// • Bullish State (green): Activated when price breaks above a major Pivot High.
// Projects upward expansion targets and keeps the trailing stop below price.
// → BUY signal printed at the ChoCh ↑
//
// • Bearish State (pink/purple): Activated when price breaks below a major Pivot Low.
// Projects downward targets and keeps the trailing stop above price.
// → SELL signal printed at the ChoCh ↓
//
// • Target Hit: each time a target level is reached, the % gain from the ChoCh
// entry is displayed on the chart.
//
// • Stop Hit: if price crosses the Trailing Stop against the active trend direction,
// an EXIT signal is printed.
//
// RECOMMENDED USAGE
// ─────────────────
// • Scalping / Day Trading → MS Length 5-8, 1m-5m charts.
// • Swing Trading → MS Length 15-20, D1 / H4 charts.
// • Risk-Reward Management → Distance ChoCh ↔ Trailing Stop = objective risk.
// Sequential targets = profit milestones.
//
// SIGNALS INCLUDED IN THIS SCRIPT
// ────────────────────────────────
// [BUY] → Bullish ChoCh confirmed (green arrow below the bar)
// [SELL] → Bearish ChoCh confirmed (pink arrow above the bar)
// [TARGET] → Price reaches a target (label with % gain above/below the bar)
// [EXIT] → Price crosses the Trailing Stop against the trend
// Configurable TradingView alerts available for all 4 events above.
// ═══════════════════════════════════════════════════════════════════════════════
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.