OPEN-SOURCE SCRIPT

Dual-Magnet Liquidity Field [DML]

10 994
📊 Dual-Magnet Liquidity Field [DML]
By PhenLabs | Pine Script v6

ảnh chụp nhanh

The Dual-Magnet Liquidity Field tracks the strongest upside liquidity target and the strongest downside liquidity target at the same time, then converts that competition into a live directional tension model.

Instead of treating every swing high or swing low equally, DML scores each candidate using distance, volume, recency, touch count, and range position. The result is a dual-sided liquidity map that shows where price is statistically being pulled, whether one side is dominant, or whether the market is compressing into a high-tension coil.

DML is built for traders who want a cleaner read on directional liquidity pressure without relying on lagging trend overlays. It is especially useful when price is moving between obvious pools, when both sides are loaded, or when one side starts to decisively overpower the other.

Points of Innovation
  • Simultaneously tracks the strongest upside and downside liquidity magnets instead of forcing a single-target view.
  • Uses a weighted probability engine that ranks confirmed swing levels by distance, volume, recency, retest density, and range location.
  • Normalizes each side’s raw score into a 0-100 tension reading against its own historical range.
  • Converts both tensions into a live dominance ratio where upside % and downside % always sum to 100.
  • Identifies two distinct states: directional bias when one side clearly dominates, and coil conditions when both sides are strong but balanced.
  • Visualizes the market as an animated dual-sided field with magnet labels, field lines, zone boxes, and a compact live gauge.


Core Components
  • Swing Magnet Engine: Detects confirmed pivot highs and pivot lows, then stores them as active liquidity candidates on both sides of price.
  • Candidate Maintenance Logic: Tracks touches, removes stale levels, and deletes magnets once they are decisively swept beyond an ATR-based mitigation threshold.
  • Probability Scoring Model: Ranks every valid candidate with a weighted composite score built from five normalized factors.
  • Tension Engine: Scales the strongest raw score on each side into a 0-100 pull reading based on its own recent history.
  • Dominance Model: Converts upside tension and downside tension into a proportional control metric that expresses directional ownership.
  • Signal Layer: Fires Bull Bias, Bear Bias, and Coil events with cooldown protection to reduce signal spam.


Key Features
  • Tracks one best upside magnet above price and one best downside magnet below price at all times.
  • Only scores levels on the correct side of price, keeping the pull model directionally clean.
  • ATR-normalized distance logic makes the indicator scale across low-volatility and high-volatility instruments.
  • Volume factor estimates how much liquidity is likely parked around a pivot relative to baseline participation.
  • Touch counting increases the score of levels that have been repeatedly tested and may hold stacked stops or resting orders.
  • Range-position logic boosts upside magnets nearer the upper range and downside magnets nearer the lower range.
  • Minimum probability threshold filters out weak magnets so only meaningful fields remain visible.
  • Animated field rendering makes strong directional pull visually obvious on the last bar.
  • Compact gauge displays upside %, downside %, raw pull, and the live field state in real time.
  • Built-in alerts support bullish dominance, bearish dominance, and balanced high-tension coil conditions.


Visualization
  • Upside Magnet: Plotted above price with a teal field, floating label, and zone box when the upside candidate qualifies.
  • Downside Magnet: Plotted below price with a red field, floating label, and zone box when the downside candidate qualifies.
  • Field Lines: Radiating lines show directional attraction from current price toward each active magnet.
  • Curved Boundary: The outer field contour helps visually frame the pull zone around each target.
  • Magnet Labels: Each label shows target price, current pull strength, and touch count.
  • Signal Markers: Triangle markers flag bull or bear bias, while a lightning symbol flags coil conditions.
  • Tension Gauge: Summarizes live dominance, raw pull, and whether the field is neutral, coiled, bullish, or bearish.


Usage Guidelines

Probability Engine

*Swing Lookback: Controls pivot significance. Higher values produce fewer, stronger swing magnets and confirm later.
*Max Candidates / Side: Sets how many recent swing highs and lows remain active in the engine.
*Min Probability Threshold: Filters out weak magnets from display and signal logic.
*Max Candidate Age: Removes older levels that are no longer relevant to current structure.
*Touch Tolerance (xATR): Defines how close price must come to count as a retest.
*Sweep Tolerance (xATR): Defines how far price must close beyond a level before that liquidity is considered taken.


Scoring Weights (advanced)</b]

*Distance Weight: Increases the impact of proximity. Higher values favor nearer magnets.
*Volume Weight: Increases the impact of relative pivot volume.
*Recency Weight: Increases the importance of fresher liquidity levels.
*Touch Weight: Gives more influence to magnets that have been repeatedly tested.
*Range-Position Weight: Adjusts the importance of where the level sits inside the active range.

Tension & Signals

*Tension Normalization Window: Defines the lookback used to scale each side’s raw score into a 0-100 tension reading.
*Dominance Threshold (%): Minimum ownership required for one side to trigger a directional bias.
*Coil Tension Floor: Minimum tension both sides must hold before a balanced coil can be flagged.
*Signal Cooldown (bars): Minimum bars between signals to reduce repetitive triggers.


Visualization</b]

*Animate Field Lines: Cycles a pulse through the field for a more dynamic read on directional attraction.
*Field Lines / Side: Controls field density.
*Pulse Period: Adjusts animation rhythm.
*Upside / Downside / Coil Colors: Customizes visual state colors.
*Show Tension Gauge: Toggles the compact dashboard.
*Gauge Position: Moves the table to the chart corner that best fits your layout.


Best Use Cases

*Identifying which side of nearby liquidity is exerting the strongest pull.
*Separating balanced compression from true directional imbalance.
*Timing continuation trades when one side clearly dominates the field.
*Monitoring mean-reversion or breakout conditions when both sides remain highly charged.
*Filtering discretionary structure reads with an objective tension model.
*Adding context to sweep-prone instruments such as crypto, indices, futures, and FX.


Limitations

*DML is a liquidity-pressure framework, not a complete trade system.
*Signals can lose effectiveness in extremely noisy, thin, or news-driven conditions.
*Because pivots are confirmed swings, new candidates appear only after confirmation delay.
*Tension is relative to recent score history, so readings should be interpreted in context rather than as absolute prediction certainty.
*Strong pull does not guarantee immediate reversal or continuation without price confirmation.


What Makes This Unique
*Most liquidity tools mark pools. DML ranks them.
*Most directional tools give a binary bias. DML shows a live 100% split between competing forces.
*Most squeeze-style tools detect compression indirectly. DML defines coil as simultaneous high, balanced attraction to both sides.
*Most target tools focus on one destination. DML keeps both magnets alive until the field resolves.


How It Works

1. Process Step 1 — Build the candidate set
Confirmed swing highs and lows are registered as upside and downside liquidity magnets. Each candidate stores its price, pivot bar, pivot volume, and a running retest count.

2. Process Step 2 — Score the strongest level on each side
Every valid candidate is scored using five normalized factors: ATR-normalized distance, relative volume, age decay, touch count, and position inside the active range. The highest composite score above price becomes the active upside magnet, and the highest composite score below price becomes the active downside magnet.

3. Process Step 3 — Convert competition into field state
The strongest raw score on each side is normalized into a 0-100 tension reading. Those tensions are then converted into upside % and downside % dominance values. When both sides are strong but balanced, DML flags a coil. When one side decisively owns the field, DML flags directional bias.

Important Note
This indicator does not future-leak its swing logic because pivots are only registered after confirmation. For best results, use DML as a liquidity-context engine alongside your execution model, structure confirmation, and risk management.

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.