K Means Liquidity Zone Clusterer MT5

  • Indicateurs
  • Anthony Cooke
    Anthony Cooke
    Quantitative Systems Architect and C++, Python, MQL5, MQL4, and Pine Script developer specializing in non-repainting mathematical indicators, Expert Advisors, and statistical strategy audits. I combine industrial quality-control engineering and Applied Mathematics with multi-physics market modeling
  • Version: 1.0

OVERVIEW AND SCIENTIFIC ORIGIN

The K Means Liquidity Zone Clusterer is a standalone, unrestricted main-chart structural indicator engineered from Unsupervised Machine Learning and Market Microstructure using Deterministic 1D Volume-Weighted Lloyd's K-Means Clustering. Rather than drawing subjective horizontal lines by eye, this engine automatically groups causally confirmed swing highs and swing lows weighted by local tick volume into objective institutional support, resistance, and Point-of-Control (POC) liquidity zones directly over candlesticks.

It runs with full unrestricted functionality across all symbols, asset classes (Forex, Gold XAUUSD, Silver XAGUSD, Indices, and Commodities), and timeframes with zero external DLL calls and 100 percent causal non-repainting calculation.


FOUR-STEP MACHINE LEARNING ENGINE

1. Causal Swing Confirmation: Identifies swing highs and swing lows strictly after InpPivotOrder (default 3) confirmed bars close to the right, guaranteeing zero repainting on closed bars. Each confirmed swing is weighted by its local 3-bar average tick volume.
2. Deterministic Empirical Quantile Seeding: Seeds K (3 to 5, default 4) initial cluster centroids across empirical price quantiles over the rolling lookback window (InpLookback = 250 bars). Deterministic seeding eliminates random initialization jitter so zones stay 100 percent identical across chart reloads.
3. Lloyd's Iterative Convergence: Executes up to 20 volume-weighted Lloyd assignment and centroid-update loops with deterministic empty-cluster recovery, sorts all clusters ascending by price, and computes each cluster's volume share (%), confirmed swing hit count, and ATR-bounded dispersion width (InpZoneWidthMult = 0.65).
4. Dynamic Role Classification: Automatically designates the highest-volume cluster as the Primary Point-of-Control (POC) Liquidity Magnet and labels surrounding clusters above or below live price as tiered Resistance (RES 1, RES 2...) and Support (SUP 1, SUP 2...).


MAIN-CHART VISUALS AND ZONE GUIDE

Active shaded liquidity boxes (width set by InpZoneBars = 100 bars) render cleanly behind candlesticks so price action stays uncluttered:
- Resistance / Supply Zones (above price): Dark crimson shaded band with a dashed Crimson centroid core line and Tomato tag.
- Support / Demand Zones (below price): Dark navy shaded band with a dashed DeepSkyBlue centroid core line and MediumSpringGreen tag.
- Primary POC Magnet / Active Pivot Zone (highest-volume cluster or zone currently containing price): Dark gold/amber shaded band with a bold solid Gold centroid core line (width 2) and Gold tag.
- Left-Shoulder Zone Tags (InpShowZoneTags = true): Anchored at the top-left of each shaded zone showing Role, Clustered Volume Share %, and Confirmed Swing Hit Count (for example: ACTIVE POC | 36% VOL (20) or SUP 1 | 29% VOL (15)).


DARK TELEMETRY HUD BOX GUIDE

Anchored at the Top-Left of the main chart by default (movable to Top-Right via InpHudRight = true) inside a dark slate panel with a DodgerBlue border:
- Line 1 (K-MEANS ZONES): Live price position relative to the cluster map (AT PRIMARY POC MAGNET or INSIDE ACTIVE PIVOT ZONE in Gold; BETWEEN LIQUIDITY ZONES in Silver) plus active cluster count K.
- Line 2 (RES and SUP): Exact price and broker-point distance to the closest overhead Resistance centroid and closest underlying Support centroid.
- Line 3 (POC): Exact price of the Primary Point-of-Control magnet, its share of clustered swing volume (%), confirmed swing hit count, and signed point distance from live close.
- Line 4 (SAMPLE): Live count of causally confirmed swing highs and lows feeding Lloyd's clustering engine over the rolling lookback window.


PRACTICAL USAGE AND PRICE DISCOVERY

- Liquidity Reactions and Targets: Watch how price reacts at high-volume RES 1 and SUP 1 bands and track pullbacks toward the bold Gold Primary POC Magnet. Higher Volume % and Swing Hit counts mark levels where institutional order flow concentrated repeatedly.
- Breakout Price Discovery: When an instrument breaks out to a fresh lookback extreme beyond all historical swings, all K clusters naturally sit on one side of price and HUD Line 2 explicitly reports RES: NEW HIGH or SUP: NEW LOW rather than inventing artificial levels.


BACKTESTING, STRATEGY TESTER AND NON-REPAINTING VERIFICATION

By default, InpShowTrails is set to false so only the active shaded zones appear on the right side of the chart, keeping live price action completely uncluttered.

To visually backtest historical cluster levels, see how institutional zones shifted bar by bar across past trends, or verify 100 percent causal non-repainting behavior in live markets or the Strategy Tester:
1. Open the indicator Inputs tab and change InpShowTrails from false to true.
2. This plots all 5 historical causal centroid line buffers (KMeans_Centroid_1 through KMeans_Centroid_5 as subtle dotted trails) across the calculation window controlled by InpMaxBars (default 800 bars; raise InpMaxBars when inspecting deeper chart history).
3. For automated Strategy Tester and Expert Advisor integration via iCustom(), three dedicated non-repainting data buffers run continuously even when visual trails are hidden: Nearest_Resistance (Buffer 5), Nearest_Support (Buffer 6), and Primary_POC_Magnet (Buffer 7).


CORE INPUT PARAMETERS AND BUFFER MAP

Clustering Engine Inputs:
- InpClusters (Default: 4, Range 3 to 5): Number of K-Means liquidity clusters.
- InpLookback (Default: 250, Range 80 to 600): Rolling bar window for collecting confirmed swings.
- InpPivotOrder (Default: 3, Range 2 to 6): Causal confirmation bars required on each side of a swing pivot.
- InpZoneBars (Default: 100, Range 30 to 300): Horizontal width of active shaded boxes in chart bars.
- InpZoneWidthMult (Default: 0.65, Range 0.25 to 1.50): Multiplier scaling ATR-bounded cluster dispersion height.

Visuals, Backtesting and HUD Inputs:
- InpShowTrails (Default: false): Set to true to plot dotted historical causal centroid trails for visual backtesting.
- InpShowZoneTags (Default: true): Toggles left-shoulder Role, Volume %, and Hit Count zone tags.
- InpShowHUD (Default: true) and InpHudRight (Default: false): Toggles the 4-line dark telemetry HUD and switches between Top-Left (false) and Top-Right (true).
- InpMaxBars (Default: 800): Maximum historical bars calculated for fast chart loading.

Expert Advisor Integration (iCustom Buffers):
Buffers 0 to 4: KMeans_Centroid_1 through KMeans_Centroid_5 (Dotted historical trails when InpShowTrails = true) | Buffer 5: Nearest_Resistance | Buffer 6: Nearest_Support | Buffer 7: Primary_POC_Magnet. Short name: KMeans_Zones(K=4,250).


USER CALIBRATION PRESETS

- Balanced Swing (Default — H1 to H4 on XAUUSD, Major Forex, US Indices): InpClusters = 4, InpLookback = 250, InpPivotOrder = 3, InpZoneWidthMult = 0.65.
- Fast Intraday and Scalping (M5 to M15): InpClusters = 3 or 4, InpLookback = 120 to 150, InpPivotOrder = 2, InpZoneWidthMult = 0.50.
- Macro Structural Levels (H4 to Daily): InpClusters = 4 or 5, InpLookback = 300 to 400, InpPivotOrder = 4, InpZoneWidthMult = 0.75.


##### FEEDBACK, RATINGS AND SUPPORT #####

If you find this indicator useful in your analysis, please consider leaving an honest star rating and review in the Reviews tab - your feedback directly guides future updates and improvements. Feel free to post any setup or calibration questions in the Comments tab.

#########################################


------Trading on MetaTrader 4 instead of MetaTrader 5? The identically engineered MetaTrader 4 edition of K Means Liquidity Zone Clusterer is available on my MQL5 Seller Profile with the exact same thumbnail, deterministic Lloyd's K-Means engine, shaded liquidity zones, dark telemetry HUD, and parameter set.

Plus de l'auteur
Overview & Scientific Origin The Fractional Differentiation Stationarity Line is an institutional quantitative indicator engineered from Financial Econometrics and Machine Learning Time-Series Theory . Popularized for institutional hedge funds by quantitative finance researcher Dr. Marcos López de Prado, Fractional Differentiation solves the oldest paradox in algorithmic trading : raw market prices contain valuable long-term trend memory but drift endlessly (making fixed indicator thresholds bre
Overview & Scientific Origin The Fractional Differentiation Stationarity Line is an institutional quantitative indicator engineered from Financial Econometrics and Machine Learning Time-Series Theory . Popularized for institutional hedge funds by quantitative finance researcher Dr. Marcos López de Prado, Fractional Differentiation solves the oldest paradox in algorithmic trading : raw market prices contain valuable long-term trend memory but drift endlessly (making fixed indicator thresholds bre
OVERVIEW AND SCIENTIFIC ORIGIN The OU Elastic Tension Meter is a standalone quantitative mean-reversion oscillator engineered from Stochastic Physics and the Ornstein-Uhlenbeck (OU) Mean-Reversion Process: dX_t = theta * (mu - X_t)dt + sigma * dW_t. Originally formulated in statistical physics to describe how particles moving through a resistive medium are pulled back toward an equilibrium anchor, the Ornstein-Uhlenbeck framework is widely applied in quantitative finance to model elastic price
FREE
OVERVIEW AND SCIENTIFIC ORIGIN The OU Elastic Tension Meter is a standalone quantitative mean-reversion oscillator engineered from Stochastic Physics and the Ornstein-Uhlenbeck (OU) Mean-Reversion Process: dX_t = theta * (mu - X_t)dt + sigma * dW_t. Originally formulated in statistical physics to describe how particles moving through a resistive medium are pulled back toward an equilibrium anchor, the Ornstein-Uhlenbeck framework is widely applied in quantitative finance to model elastic price
FREE
Overview & Scientific Origin The Navier-Stokes Fluid Reynolds Breakout Meter is an institutional quantitative indicator engineered from Fluid Dynamics and Aerospace Engineering . In physics and mechanical engineering, the Navier-Stokes equations and the dimensionless Reynolds Number are used to predict the exact threshold where a fluid—such as airflow over a supersonic jet wing or crude oil moving through a high-pressure pipeline—transitions from smooth, predictable laminar flow into chaotic, h
Overview & Scientific Origin The Hodgkin-Huxley Neuro-Synaptic Action Spike is an institutional quantitative indicator engineered from Computational Neurobiology and Biophysics . Developed by Nobel Prize-winning biophysicists Alan Hodgkin and Andrew Huxley to model how electrical signals travel through the human brain and nervous system, the Hodgkin-Huxley equations describe how a biological neuron absorbs small, random electrical disturbances until the charge crosses a critical threshold—causin
Overview & Scientific Origin The Seismic Omori Fault Line Aftershock Decay is an institutional quantitative indicator engineered from Geophysics and Earthquake Seismology . In seismology, the Modified Omori-Utsu Law is used to forecast the exact power-law decay rate of aftershocks following a major tectonic earthquake—telling scientists how long a fault line remains unstable before seismic activity returns to normal. This indicator applies seismic hazard decay to financial volatility spikes, sho
Overview & Scientific Origin The Institutional Fair Value Gap Liquidity Net is an institutional quantitative indicator engineered from Market Microstructure and Electronic Order-Book Theory (Smart Money Concepts) . In institutional execution desks and interbank liquidity pools, aggressive high-volume market orders frequently sweep resting limit orders faster than market makers can replenish the book. This displacement leaves behind measurable three-candle price voids—known as Fair Value Gaps (FV
Overview & Scientific Origin The Quantum Feynman Path Integral Oscillator is an institutional quantitative indicator engineered from Quantum Field Theory and Theoretical Physics. Developed by Nobel Prize-winning physicist Richard Feynman, the Path-Integral formulation is used in quantum mechanics and particle physics to evaluate every trajectory a subatomic particle can take between two states—calculating whether waves cancel each other out inside a confining "potential well" or align construct
Overview & Scientific Origin The Hawkes Self Exciting Volatility Cascade is an institutional quantitative indicator engineered from Stochastic Point-Process Theory and High-Frequency Trading (HFT) Microstructure. Originally developed by statistician Alan Hawkes to model self-exciting earthquake chains and viral contagion, Hawkes Processes are widely deployed by institutional market makers and HFT desks to detect real-time order-book clustering—where a single aggressive institutional sweep trigg
Overview & Scientific Origin The Soliton Kdv Rogue Wave Detector is an institutional quantitative indicator engineered from Nonlinear Fluid Physics and Oceanography. Based on the classic Korteweg-de Vries (KdV) partial differential equation, this branch of physics studies solitons (self-reinforcing solitary waves, such as deep-ocean tsunamis or fiber-optic light pulses, that travel long distances without breaking apart or losing energy) and rogue waves (sudden high-amplitude wave surges where n
Overview & Scientific Origin The Thermodynamic Fokker Planck Helmholtz Energy is an institutional quantitative indicator engineered from Statistical Mechanics and Non-Equilibrium Thermodynamics. In physics and physical chemistry, the Fokker-Planck equation measures how a system of particles evolves under directional drift versus random thermal diffusion, while Helmholtz Free Energy (F = U - T · S) calculates how much usable mechanical work a system can perform once heat (T) and random disorder
Overview & Scientific Origin The Bullion Dollar StatArb Gauge Loop is an institutional quantitative indicator engineered from Quantitative Pairs Trading (Statistical Arbitrage) and Lattice Gauge Theory (Theoretical Physics). Institutional prop desks use rolling Ordinary Least Squares (OLS) dynamic hedge ratios to measure when two correlated markets diverge abnormally far from fair value, while physicists use Wilson Gauge Loop Phase Holonomy to measure rotational flux and lead-lag curvature arou
Overview & Scientific Origin The Omni Spectrum Fibonacci Harmonic Ribbon is an institutional main-chart trend-regime indicator engineered from Multi-Scale Spectral Trend Analysis and Golden-Ratio Number Theory. In quantitative signal processing, decomposing price across logarithmically spaced frequency horizons separates short-term market noise from deep macro order flow. By synchronizing six Exponential Moving Averages along the exact Fibonacci sequence (13, 21, 34, 55, 89, 144)—where each lay
Overview & Scientific Origin The Variational Mode Lorenz Chaotic Attractor is a flagship institutional quantitative indicator engineered from Adaptive Signal Processing (Variational Mode Decomposition) and Nonlinear Chaos Dynamics (Edward Lorenz's 3D Strange Attractor). In aerospace telemetry, seismology, and biomedical engineering, Variational Mode Decomposition (VMD) is an advanced spectral optimization algorithm used to break a noisy, non-stationary signal into clean, non-overlapping frequen
OVERVIEW AND SCIENTIFIC ORIGIN The Multi Physics Veto Matrix is an institutional quantitative consensus and trade-filtering indicator engineered from five branches of applied physics and econometrics: Fractional Calculus, Fluid Dynamics, Computational Neurobiology, Statistical Mechanics, and Stochastic Mean-Reversion Theory. Powered by the internal ME.v2 multi-physics consensus engine, which is displayed on the live subwindow telemetry readout. Designed as a complementary flagship module on th
OVERVIEW AND INSTITUTIONAL RISK ORIGIN The Three Stage ATR Ratchet Manager is an institutional trade-management and equity-governance Expert Advisor engineered from Quantitative Risk Management and Asymmetric Stop-Loss Control Theory. Professional proprietary trading desks and systematic risk officers do not manage trades with static pip stops or fixed lot sizes because market volatility expands and contracts constantly across assets and sessions. A 20-pip stop that works on a calm EURUSD morni
OVERVIEW AND SCIENTIFIC ORIGIN The Alpha Decay Half Life Auditor is a dual-engine quantitative indicator engineered from Stochastic Physics (Ornstein-Uhlenbeck Mean-Reversion Dynamics) and Quantitative Strategy Auditing. In institutional portfolio management, directional trading signals do not stay valid indefinitely: market regimes shift between persistent trending behavior and rapid mean-reverting chop, while individual trading strategies experience measurable alpha decay as holding time leng
OVERVIEW AND SCIENTIFIC ORIGIN The Kalman Dynamic Beta Engine is a quantitative statistical arbitrage and state-space indicator engineered from Control Theory and Financial Econometrics (Recursive Kalman Filtering). Originally developed for aerospace navigation and radar tracking to estimate hidden moving states from noisy measurements, the Kalman Filter is widely applied in quantitative pairs trading to track how the hedge ratio (Beta) between two correlated markets evolves in real time. Unli
OVERVIEW AND SCIENTIFIC ORIGIN The VPIN Flow Toxicity Meter is an institutional order-flow and market-microstructure indicator engineered from High-Frequency Market-Making Theory (Volume-Synchronized Probability of Informed Trading, introduced by David Easley, Marcos Lopez de Prado, and Maureen O'Hara). In electronic exchanges and institutional liquidity desks, market makers track order-flow toxicity to measure adverse selection risk—the moments when informed institutional buyers or sellers flo
OVERVIEW AND SCIENTIFIC ORIGIN The Hidden Markov Regime Engine is a quantitative market-state indicator engineered from Probabilistic Machine Learning and Quantitative Econometrics (3-State Gaussian Hidden Markov Model using the Hamilton-Kim Online Forward Filter). Used by systematic asset managers to identify hidden market regimes, a forward-only Hidden Markov Model estimates the live probability of each market state strictly from past and current bars without backward Viterbi smoothing and wi
OVERVIEW AND SCIENTIFIC ORIGIN The Marchenko Pastur RMT Denoiser is a quantitative spectral filter engineered from Random Matrix Theory (RMT) and Quantitative Econophysics, implementing the Marchenko-Pastur Eigenvalue Law, the Laloux-Cizeau-Bouchaud-Potters (LCBP) bulk noise boundary, and Baik-Ben Arous-Peche (BBP) signal subspace shrinkage natively in MQL without external DLLs. In institutional econophysics and quantitative portfolio desks, Random Matrix Theory separates genuine non-random ma
OVERVIEW AND SCIENTIFIC ORIGIN The Kyle Lambda Liquidity Impact indicator is an institutional market-microstructure tool engineered from Liquidity Economics, combining Kyle (1985) Price-Impact Lambda with Hasbrouck (2009) Square-Root Volume Scaling. In institutional execution desks, Kyle's Lambda measures market illiquidity: how much price moves per unit of incoming order volume. IMPORTANT — NOT A PRICE-DIRECTION OSCILLATOR: This subwindow wave measures ORDER-BOOK DEPTH AND LIQUIDITY STRUCTURE
OVERVIEW AND SCIENTIFIC ORIGIN The GKYZ Volatility Estimator is an institutional range-and-gap volatility indicator engineered from Quantitative Finance and Volatility Econometrics, combining the Garman-Klass (1980) OHLC range estimator with the Yang-Zhang (2000) overnight-gap variance extension (GKYZ). Standard close-to-close standard deviation ignores everything that happens inside a candle's high-low wicks, while naive ATR mixes volatility with absolute price scale. By incorporating Open, H
OVERVIEW AND SCIENTIFIC ORIGIN The Extreme Value Tail Risk Engine is a quantitative risk-monitoring and tail-shock oscillator engineered from Actuarial Statistics, Quantitative Risk Management, and Extreme Value Theory (Peaks-Over-Threshold Generalized Pareto Distribution [POT-GPD] paired with the Hill Power-Law Tail Index). Standard Gaussian risk indicators and Bollinger-style bands assume normal bell-curve returns and routinely underestimate sudden market crashes and short-squeeze melt-ups.
OVERVIEW AND SCIENTIFIC ORIGIN The Hilbert Huang Phase Analyzer is a cycle-timing and instantaneous-phase indicator engineered from Nonlinear Signal Processing and Empirical Mode Decomposition (the Huang et al. Hilbert-Huang Transform [HHT], adapted into a 100 percent causal real-time digital signal processor). Traditional oscillators use fixed-period lookbacks that lag sharply whenever market swing rhythm speeds up or slows down, and they fail during strong directional trends. This strictly c
OVERVIEW AND SCIENTIFIC ORIGIN The K Means Liquidity Zone Clusterer is a standalone, unrestricted main-chart structural indicator engineered from Unsupervised Machine Learning and Market Microstructure using Deterministic 1D Volume-Weighted Lloyd's K-Means Clustering. Rather than drawing subjective horizontal lines by eye, this engine automatically groups causally confirmed swing highs and swing lows weighted by local tick volume into objective institutional support, resistance, and Point-of-Co
FREE
Overview & Scientific Origin The Navier-Stokes Fluid Reynolds Breakout Meter is an institutional quantitative indicator engineered from Fluid Dynamics and Aerospace Engineering . In physics and mechanical engineering, the Navier-Stokes equations and the dimensionless Reynolds Number are used to predict the exact threshold where a fluid—such as airflow over a supersonic jet wing or crude oil moving through a high-pressure pipeline—transitions from smooth, predictable laminar flow into chaotic, hi
Overview & Scientific Origin The Hodgkin-Huxley Neuro-Synaptic Action Spike is an institutional quantitative indicator engineered from Computational Neurobiology and Biophysics . Developed by Nobel Prize-winning biophysicists Alan Hodgkin and Andrew Huxley to model how electrical signals travel through the human brain and nervous system, the Hodgkin-Huxley equations describe how a biological neuron absorbs small, random electrical disturbances until the charge crosses a critical threshold—causi
Overview & Scientific Origin The Seismic Omori Fault Line Aftershock Decay is an institutional quantitative indicator engineered from Geophysics and Earthquake Seismology . In seismology, the Modified Omori-Utsu Law is used to forecast the exact power-law decay rate of aftershocks following a major tectonic earthquake—telling scientists how long a fault line remains unstable before seismic activity returns to normal.This indicator applies seismic hazard decay to financial volatility spikes, show
Filtrer:
Aucun avis
Répondre à l'avis