OPEN-SOURCE SCRIPT
Structural Layer 2: Execution State Engine

The Structural Layer 2: Execution State Engine is a first-principles market classifier that strips away lagging indicators to analyze the raw relationship between price velocity and volume.
Built from scratch using rolling mathematical Z-scores, this indicator measures real-time market effort versus result. It compares current price spread (velocity) and external exchange volume against their structural baselines, grouping price action into four distinct "Execution States."
By categorizing every bar based on standard deviations from the mean, it visually highlights whether a move is backed by true conviction, being absorbed by larger players, or simply drifting on thin liquidity.
🚦 The 4 Execution States (Color Coded)
This indicator paints your chart’s bars to reveal the underlying market state (optimized for white backgrounds):
🔵 Blue (State A - Breakout Momentum): High Velocity + High Volume. True directional conviction. Price is covering significant distance backed by heavy participation.
🟠 Orange (State B - Institutional Absorption): Low Velocity + High Volume. High effort, low result. Heavy volume is entering the market, but the price isn't moving. This signals potential absorption, accumulation, or distribution by larger participants.
🟣 Purple (State D - Fragile Vacuum): High Velocity + Low Volume. Fast price movement on thin air. These are low-liquidity vacuum moves that are structurally fragile and often prone to mean reversion.
⚪ Light Gray (State C - No-Trade Drift): Low Velocity + Low Volume. The baseline noise. No significant volume and no significant price movement. Generally a chop or no-trade zone.
⚙️ Key Features
External Volume Routing: Fetch volume directly from major exchanges (default: Binance/Coinbase SOLUSD) to bypass localized data gaps and get a truer read on market participation.
Math from First Principles: Relies strictly on raw math (rolling means, variance, and Z-scores) instead of wrapped, smoothed TA functions that introduce lag.
Customizable Lookback: Adjust the structural lookback window (default: 48 hours) to tune the engine to your preferred timeframe and volatility baseline.
How to Use:
Use the bar colors to dictate your execution style. Ride momentum on Blue bars, look for reversals or traps on Orange bars, be cautious of fake-outs on Purple bars, and protect your capital from chop on Gray bars.
Built from scratch using rolling mathematical Z-scores, this indicator measures real-time market effort versus result. It compares current price spread (velocity) and external exchange volume against their structural baselines, grouping price action into four distinct "Execution States."
By categorizing every bar based on standard deviations from the mean, it visually highlights whether a move is backed by true conviction, being absorbed by larger players, or simply drifting on thin liquidity.
🚦 The 4 Execution States (Color Coded)
This indicator paints your chart’s bars to reveal the underlying market state (optimized for white backgrounds):
🔵 Blue (State A - Breakout Momentum): High Velocity + High Volume. True directional conviction. Price is covering significant distance backed by heavy participation.
🟠 Orange (State B - Institutional Absorption): Low Velocity + High Volume. High effort, low result. Heavy volume is entering the market, but the price isn't moving. This signals potential absorption, accumulation, or distribution by larger participants.
🟣 Purple (State D - Fragile Vacuum): High Velocity + Low Volume. Fast price movement on thin air. These are low-liquidity vacuum moves that are structurally fragile and often prone to mean reversion.
⚪ Light Gray (State C - No-Trade Drift): Low Velocity + Low Volume. The baseline noise. No significant volume and no significant price movement. Generally a chop or no-trade zone.
⚙️ Key Features
External Volume Routing: Fetch volume directly from major exchanges (default: Binance/Coinbase SOLUSD) to bypass localized data gaps and get a truer read on market participation.
Math from First Principles: Relies strictly on raw math (rolling means, variance, and Z-scores) instead of wrapped, smoothed TA functions that introduce lag.
Customizable Lookback: Adjust the structural lookback window (default: 48 hours) to tune the engine to your preferred timeframe and volatility baseline.
How to Use:
Use the bar colors to dictate your execution style. Ride momentum on Blue bars, look for reversals or traps on Orange bars, be cautious of fake-outs on Purple bars, and protect your capital from chop on Gray bars.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.