OPEN-SOURCE SCRIPT
Market Entropy Scanner

Market Entropy Scanner (MES)
An Adaptive Trend and Reversal Analysis System
Where Volatility Dynamics Meet Signal Confluence.
🎓 THEORETICAL FOUNDATION
The Market Entropy Scanner (MES) is an integrated technical analysis system designed to identify high-probability trend continuations and mean-reversion opportunities. Its core philosophy is based on the principle of confluence—that the most reliable signals occur when multiple, uncorrelated analytical concepts align.
The MES architecture is built upon a hierarchy of specialized engines that work in concert to score market conditions, from the macro trend down to the microstructure of individual candles.
Pillar 1: Dynamic Volatility Scaling (DVS) Engine
The market is not static; it transitions between states of low and high volatility. The DVS engine is the adaptive brain of the MES. It continuously measures the market's current volatility against a longer-term baseline using one of four statistical methods (including the advanced Garman-Klass model). The resulting ratio dynamically tunes the indicator's core parameters, such as the Supertrend and RSI lengths.
In high-volatility (trending) environments, parameters become shorter for faster responsiveness.
In low-volatility (ranging) environments, parameters become longer to filter out noise and prevent false signals.
Pillar 2: Zero-Lag Supertrend Core
The system's foundation for trend direction is a Zero-Lag Supertrend. By using a Zero-Lag EMA (ZLEMA) as its baseline, it reduces the inherent lag of traditional Supertrend indicators, providing more timely trend-flip signals. Crucially, it also calculates "Extremity Zones"—dynamic thresholds measured in ATR multiples away from the Supertrend line. Price action that enters these zones is considered statistically over-extended, a primary condition for enabling reversal signals.
Pillar 3: Wick Pressure & Divergence Kernels
To identify reversals, MES quantifies exhaustion and momentum loss:
Wick Pressure Kernel: This engine analyzes candle microstructure, measuring the ratio of upper and lower wicks to the candle's total range. A high positive score indicates strong buying pressure (long lower wicks), while a high negative score indicates selling pressure (long upper wicks). This provides a quantifiable measure of price rejection.
Divergence Engine: The system scans for classical divergences between price pivots and RSI pivots. A valid divergence is only confirmed if it occurs while price is within an Extremity Zone, filtering for divergences that happen at points of maximum trend exhaustion.
Pillar 4: Footprint Intelligence Layer (Optional)
For maximum analytical depth, MES can integrate tick-level footprint data. When enabled, this layer provides two key enhancements:
Delta-Enhanced Pressure: The Wick Pressure score is blended with the bar's real delta (net difference between buying and selling volume), grounding the candle analysis with confirmed order flow data.
Structural Confluence: The Point of Control (POC) and Value Area (VA) for each bar are displayed, providing key intra-bar levels of support and resistance that can be used to validate signals.
Pillar 5: Integrated Trade & Performance Module
MES is a complete system that includes a full suite of trade management tools. It features an ATR-based exit strategy with defined profit targets and stop-losses, a sophisticated trailing stop mechanism, and the option for intra-bar exits for maximum precision. A built-in performance tracker logs all simulated trades, providing key metrics like Win Rate and Profit Factor directly on the dashboard.
🔧 COMPREHENSIVE INPUT SYSTEM
🧬 DVS Engine
Enable DVS: Master switch for the Dynamic Volatility Scaling engine. When enabled, it adapts key parameters based on market volatility. When disabled, the indicator uses the fixed "Base" values.
Volatility Method: Selects the formula for volatility estimation. Options include ATR Ratio (simple), Parkinson (efficient), Garman-Klass (statistically advanced), and Ensemble (most stable median of all three).
Volatility Memory: The lookback period for establishing the baseline average volatility.
DVS Smoothing: Applies an EMA to the final DVS ratio to ensure smooth transitions between regimes.
Sensitivity: A multiplier controlling the intensity of the adaptation. >1.0 exaggerates the effect; <1.0 dampens it.
⚡ ZeroLag Supertrend
Base Length: The base lookback period for the Supertrend, used as the 'slow' setting in low-volatility conditions.
Base Multiplier: The ATR multiplier that sets the width of the Supertrend channel. Higher values are less sensitive; lower values are more responsive.
Extremity Threshold (ATR): Defines how far price must move from the Supertrend line (in ATR multiples) to be flagged as 'extreme', enabling reversal signals.
Show Extremity Zones: Toggles the shaded boxes that visualize the overbought/oversold zones.
🕯️ Wick Pressure Kernel
Pressure Smoothing: The EMA smoothing period for the Wick Pressure calculation, creating a more stable reading.
Signal Threshold: The minimum normalized wick pressure value required to contribute to the signal score, acting as a quality filter.
📐 Divergence Engine
Pivot Lookback: The number of bars left and right to confirm a valid price/RSI pivot. Higher values find more significant swing points.
RSI Length: The base lookback period for the RSI. This value is adapted by the DVS engine.
🔬 Footprint
Enable Footprint: Master switch for all footprint features. Requires a data plan that supports it.
Ticks per Row: Sets the price resolution for the footprint profile.
Value Area %: The percentage of volume contained within the Value Area.
Delta Blend into Wick: Controls the influence of real footprint delta on the Wick Pressure calculation (0.0 = none, 0.8 = high).
Show POC/VA: Toggles visibility for the Point of Control and Value Area lines.
🎯 Exit & Targets
Show Target/Stop Levels: Toggles visibility of the TP/SL lines for an active trade.
Target/Stop ATR Multiple: Sets the profit target and initial stop-loss distance as a multiple of the 14-period ATR at entry.
Trailing Stop ATR: The ATR multiple for the trailing stop distance.
Trail Activation (% of target): The percentage of profit (from entry to target) that must be achieved before the trailing stop becomes active.
Intra-Bar Exits: If enabled, checks for exits on every tick. If disabled, exits are processed only on bar close.
🎨 ADVANCED VISUAL SYSTEM
Core Trend & Channel
Zero-Lag Supertrend: The main line on the chart, colored bullish or bearish to indicate the current trend direction.
Adaptive Channel: The upper and lower bands of the Supertrend are plotted with a transparent fill, creating a clear visual channel that expands and contracts with volatility.

Regime Background: The chart background is subtly shaded based on the trend direction and intensifies when price enters an Extremity Zone.

Reversal & Pressure Visuals
Extremity Zones: Shaded boxes appear in real-time when price becomes statistically
over-extended, visually highlighting potential reversal areas.

Divergence Labels: A "DIV" label appears below bullish divergences and above bearish divergences, pinpointing the exact moment of momentum loss.
Wick Pressure Bar Coloring: Chart bars are colored based on the strength of the smoothed Wick Pressure, providing an immediate, intuitive sense of buying (bullish color) or selling (bearish color) pressure.
Footprint & Trade Management Visuals
POC & Value Area: When enabled, the POC, VAH, and VAL are plotted as steplines for each bar, offering key intra-bar structural levels.
Target & Stop Levels: For any active trade, the entry price, profit target, and stop-loss are clearly plotted as horizontal lines, providing an objective view of the trade's parameters. The stop-loss line changes color when the trailing stop is activated.
📊 INSTITUTIONAL-GRADE DASHBOARD
The dashboard provides a comprehensive, at-a-glance summary of every component of the system.
DVS Engine Section: Displays the real-time Volatility Ratio, the current Volatility Regime (High, Normal, Low), and the dynamically adapted lengths for the Supertrend and RSI.
Signals Section: Shows the current trend direction, the distance of price from the Supertrend (in ATRs), the current Wick Pressure and RSI values, and the calculated scores (0-100%) for potential Long and Short reversal signals.
Status Section: Confirms the current market zone (Overbought, Oversold), any active divergences, and the status of the signal cooldown timer.
Footprint Section: If active, displays the bar's real-time Delta and Point of Control price.
Position & Performance Section: If tracking is enabled, shows the current position (Flat, Long, Short), unrealized P&L, and key performance metrics like Total Trades, Win Rate (%), Profit Factor, and Expectancy (%).
Master Status Bar: A text field at the bottom provides a clear, human-readable summary of the most important current event (e.g., "▲ REV BUY SIGNAL", "⚠ OVERBOUGHT ZONE").
🎯 SIGNAL GENERATION LOGIC
MES utilizes a sophisticated scoring system for its primary reversal signals. A signal is not triggered by a single event but by the accumulation of a high score based on the confluence of multiple conditions.
Scoring System Breakdown:
Base Score: A significant score is awarded if price is in an Extremity Zone (Oversold for Longs, Overbought for Shorts). This is the foundational requirement.
Wick Pressure Score: The score increases if the Wick Pressure is strong and in the desired direction (e.g., high positive pressure for a Long signal).
Divergence Score: The score receives a substantial boost if a confirmed Divergence is present. The strength of the divergence also contributes.
Momentum Confirmation: A smaller score is added if the ZLEMA baseline has flattened or started to turn, indicating the primary trend is losing momentum.
Footprint Confirmation (Optional): If enabled, the score gets an additional boost if the real-time Delta supports the signal direction.
A final signal is generated only if the total score exceeds a predefined threshold (e.g., 45%) and the signal cooldown period has passed, ensuring only high-conviction setups are flagged.
⚖️ RESPONSIBLE USAGE AND LIMITATIONS
Not a Standalone System: MES is a powerful decision-support tool. It should be used in conjunction with sound risk management, position sizing, and an understanding of the broader market context.
Parameter Optimization: While the DVS engine provides robust adaptation, optimal performance may still require tuning of base parameters (like the Supertrend Multiplier or Extremity Threshold) to suit specific assets and timeframes.
Past Performance: The performance metrics displayed are based on a simulation of past data. This is not a guarantee of future results. Market conditions change, and the system's effectiveness can vary.
Data Requirements: The optional Footprint layer requires a premium data feed. The indicator will function fully without it but will lack the delta-enhancement features.
🔮 CONCLUSION
The Market Entropy Scanner (MES) is a comprehensive analysis tool designed for the discerning trader. It moves beyond static indicators by integrating a dynamic, self-adapting engine that adjusts to changing market conditions in real-time. By systematically scoring the confluence of trend exhaustion, momentum divergence, and candle pressure, it provides a clear, objective, and data-driven framework for identifying potential market turning points.
With its integrated exit logic and performance tracking, MES offers a complete, self-contained system for developing and testing structured trading approaches.
— Dskyz, Trade with insight. Trade with anticipation. (All day, Everyday)
An Adaptive Trend and Reversal Analysis System
Where Volatility Dynamics Meet Signal Confluence.
🎓 THEORETICAL FOUNDATION
The Market Entropy Scanner (MES) is an integrated technical analysis system designed to identify high-probability trend continuations and mean-reversion opportunities. Its core philosophy is based on the principle of confluence—that the most reliable signals occur when multiple, uncorrelated analytical concepts align.
The MES architecture is built upon a hierarchy of specialized engines that work in concert to score market conditions, from the macro trend down to the microstructure of individual candles.
Pillar 1: Dynamic Volatility Scaling (DVS) Engine
The market is not static; it transitions between states of low and high volatility. The DVS engine is the adaptive brain of the MES. It continuously measures the market's current volatility against a longer-term baseline using one of four statistical methods (including the advanced Garman-Klass model). The resulting ratio dynamically tunes the indicator's core parameters, such as the Supertrend and RSI lengths.
In high-volatility (trending) environments, parameters become shorter for faster responsiveness.
In low-volatility (ranging) environments, parameters become longer to filter out noise and prevent false signals.
Pillar 2: Zero-Lag Supertrend Core
The system's foundation for trend direction is a Zero-Lag Supertrend. By using a Zero-Lag EMA (ZLEMA) as its baseline, it reduces the inherent lag of traditional Supertrend indicators, providing more timely trend-flip signals. Crucially, it also calculates "Extremity Zones"—dynamic thresholds measured in ATR multiples away from the Supertrend line. Price action that enters these zones is considered statistically over-extended, a primary condition for enabling reversal signals.
Pillar 3: Wick Pressure & Divergence Kernels
To identify reversals, MES quantifies exhaustion and momentum loss:
Wick Pressure Kernel: This engine analyzes candle microstructure, measuring the ratio of upper and lower wicks to the candle's total range. A high positive score indicates strong buying pressure (long lower wicks), while a high negative score indicates selling pressure (long upper wicks). This provides a quantifiable measure of price rejection.
Divergence Engine: The system scans for classical divergences between price pivots and RSI pivots. A valid divergence is only confirmed if it occurs while price is within an Extremity Zone, filtering for divergences that happen at points of maximum trend exhaustion.
Pillar 4: Footprint Intelligence Layer (Optional)
For maximum analytical depth, MES can integrate tick-level footprint data. When enabled, this layer provides two key enhancements:
Delta-Enhanced Pressure: The Wick Pressure score is blended with the bar's real delta (net difference between buying and selling volume), grounding the candle analysis with confirmed order flow data.
Structural Confluence: The Point of Control (POC) and Value Area (VA) for each bar are displayed, providing key intra-bar levels of support and resistance that can be used to validate signals.
Pillar 5: Integrated Trade & Performance Module
MES is a complete system that includes a full suite of trade management tools. It features an ATR-based exit strategy with defined profit targets and stop-losses, a sophisticated trailing stop mechanism, and the option for intra-bar exits for maximum precision. A built-in performance tracker logs all simulated trades, providing key metrics like Win Rate and Profit Factor directly on the dashboard.
🔧 COMPREHENSIVE INPUT SYSTEM
🧬 DVS Engine
Enable DVS: Master switch for the Dynamic Volatility Scaling engine. When enabled, it adapts key parameters based on market volatility. When disabled, the indicator uses the fixed "Base" values.
Volatility Method: Selects the formula for volatility estimation. Options include ATR Ratio (simple), Parkinson (efficient), Garman-Klass (statistically advanced), and Ensemble (most stable median of all three).
Volatility Memory: The lookback period for establishing the baseline average volatility.
DVS Smoothing: Applies an EMA to the final DVS ratio to ensure smooth transitions between regimes.
Sensitivity: A multiplier controlling the intensity of the adaptation. >1.0 exaggerates the effect; <1.0 dampens it.
⚡ ZeroLag Supertrend
Base Length: The base lookback period for the Supertrend, used as the 'slow' setting in low-volatility conditions.
Base Multiplier: The ATR multiplier that sets the width of the Supertrend channel. Higher values are less sensitive; lower values are more responsive.
Extremity Threshold (ATR): Defines how far price must move from the Supertrend line (in ATR multiples) to be flagged as 'extreme', enabling reversal signals.
Show Extremity Zones: Toggles the shaded boxes that visualize the overbought/oversold zones.
🕯️ Wick Pressure Kernel
Pressure Smoothing: The EMA smoothing period for the Wick Pressure calculation, creating a more stable reading.
Signal Threshold: The minimum normalized wick pressure value required to contribute to the signal score, acting as a quality filter.
📐 Divergence Engine
Pivot Lookback: The number of bars left and right to confirm a valid price/RSI pivot. Higher values find more significant swing points.
RSI Length: The base lookback period for the RSI. This value is adapted by the DVS engine.
🔬 Footprint
Enable Footprint: Master switch for all footprint features. Requires a data plan that supports it.
Ticks per Row: Sets the price resolution for the footprint profile.
Value Area %: The percentage of volume contained within the Value Area.
Delta Blend into Wick: Controls the influence of real footprint delta on the Wick Pressure calculation (0.0 = none, 0.8 = high).
Show POC/VA: Toggles visibility for the Point of Control and Value Area lines.
🎯 Exit & Targets
Show Target/Stop Levels: Toggles visibility of the TP/SL lines for an active trade.
Target/Stop ATR Multiple: Sets the profit target and initial stop-loss distance as a multiple of the 14-period ATR at entry.
Trailing Stop ATR: The ATR multiple for the trailing stop distance.
Trail Activation (% of target): The percentage of profit (from entry to target) that must be achieved before the trailing stop becomes active.
Intra-Bar Exits: If enabled, checks for exits on every tick. If disabled, exits are processed only on bar close.
🎨 ADVANCED VISUAL SYSTEM
Core Trend & Channel
Zero-Lag Supertrend: The main line on the chart, colored bullish or bearish to indicate the current trend direction.
Adaptive Channel: The upper and lower bands of the Supertrend are plotted with a transparent fill, creating a clear visual channel that expands and contracts with volatility.
Regime Background: The chart background is subtly shaded based on the trend direction and intensifies when price enters an Extremity Zone.
Reversal & Pressure Visuals
Extremity Zones: Shaded boxes appear in real-time when price becomes statistically
over-extended, visually highlighting potential reversal areas.
Divergence Labels: A "DIV" label appears below bullish divergences and above bearish divergences, pinpointing the exact moment of momentum loss.
Wick Pressure Bar Coloring: Chart bars are colored based on the strength of the smoothed Wick Pressure, providing an immediate, intuitive sense of buying (bullish color) or selling (bearish color) pressure.
Footprint & Trade Management Visuals
POC & Value Area: When enabled, the POC, VAH, and VAL are plotted as steplines for each bar, offering key intra-bar structural levels.
Target & Stop Levels: For any active trade, the entry price, profit target, and stop-loss are clearly plotted as horizontal lines, providing an objective view of the trade's parameters. The stop-loss line changes color when the trailing stop is activated.
📊 INSTITUTIONAL-GRADE DASHBOARD
The dashboard provides a comprehensive, at-a-glance summary of every component of the system.
DVS Engine Section: Displays the real-time Volatility Ratio, the current Volatility Regime (High, Normal, Low), and the dynamically adapted lengths for the Supertrend and RSI.
Signals Section: Shows the current trend direction, the distance of price from the Supertrend (in ATRs), the current Wick Pressure and RSI values, and the calculated scores (0-100%) for potential Long and Short reversal signals.
Status Section: Confirms the current market zone (Overbought, Oversold), any active divergences, and the status of the signal cooldown timer.
Footprint Section: If active, displays the bar's real-time Delta and Point of Control price.
Position & Performance Section: If tracking is enabled, shows the current position (Flat, Long, Short), unrealized P&L, and key performance metrics like Total Trades, Win Rate (%), Profit Factor, and Expectancy (%).
Master Status Bar: A text field at the bottom provides a clear, human-readable summary of the most important current event (e.g., "▲ REV BUY SIGNAL", "⚠ OVERBOUGHT ZONE").
🎯 SIGNAL GENERATION LOGIC
MES utilizes a sophisticated scoring system for its primary reversal signals. A signal is not triggered by a single event but by the accumulation of a high score based on the confluence of multiple conditions.
Scoring System Breakdown:
Base Score: A significant score is awarded if price is in an Extremity Zone (Oversold for Longs, Overbought for Shorts). This is the foundational requirement.
Wick Pressure Score: The score increases if the Wick Pressure is strong and in the desired direction (e.g., high positive pressure for a Long signal).
Divergence Score: The score receives a substantial boost if a confirmed Divergence is present. The strength of the divergence also contributes.
Momentum Confirmation: A smaller score is added if the ZLEMA baseline has flattened or started to turn, indicating the primary trend is losing momentum.
Footprint Confirmation (Optional): If enabled, the score gets an additional boost if the real-time Delta supports the signal direction.
A final signal is generated only if the total score exceeds a predefined threshold (e.g., 45%) and the signal cooldown period has passed, ensuring only high-conviction setups are flagged.
⚖️ RESPONSIBLE USAGE AND LIMITATIONS
Not a Standalone System: MES is a powerful decision-support tool. It should be used in conjunction with sound risk management, position sizing, and an understanding of the broader market context.
Parameter Optimization: While the DVS engine provides robust adaptation, optimal performance may still require tuning of base parameters (like the Supertrend Multiplier or Extremity Threshold) to suit specific assets and timeframes.
Past Performance: The performance metrics displayed are based on a simulation of past data. This is not a guarantee of future results. Market conditions change, and the system's effectiveness can vary.
Data Requirements: The optional Footprint layer requires a premium data feed. The indicator will function fully without it but will lack the delta-enhancement features.
🔮 CONCLUSION
The Market Entropy Scanner (MES) is a comprehensive analysis tool designed for the discerning trader. It moves beyond static indicators by integrating a dynamic, self-adapting engine that adjusts to changing market conditions in real-time. By systematically scoring the confluence of trend exhaustion, momentum divergence, and candle pressure, it provides a clear, objective, and data-driven framework for identifying potential market turning points.
With its integrated exit logic and performance tracking, MES offers a complete, self-contained system for developing and testing structured trading approaches.
— Dskyz, Trade with insight. Trade with anticipation. (All day, Everyday)
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.