Inverseprobabilitydistribution
- Indicadores
-
Shi Yuan Wang
Desenvolvo indicadores personalizados, Expert Advisors (EAs), scripts e ferramentas de trading para MetaTrader 4 e MetaTrader 5, e indicadores para TradingView (Pine Script).
O que posso fazer por si: - Versão: 1.0
Inverse probability distribution — Analytical Visualization Tool Based on Pivot Points & K-Means Clustering
Overview
This indicator is a pure technical-analysis visualization tool for MetaTrader 5. It detects confirmed pivot highs/lows on historical bars, groups pivot prices using K-Means clustering, and builds a Inverse probability distribution projected to the right of the chart — allowing traders to visually inspect how pivot points are statistically distributed across price levels.
⚠️ This indicator does not generate trading signals and does not execute any trades. It only presents a statistical distribution of historical pivot points and reference support/resistance levels on the chart.
How It Works
- Pivot Detection — Using user-defined left/right bar parameters, each bar is strictly evaluated as a pivot high (local maximum of high ) or pivot low (local minimum of low ).
- Pivot Memory & Pruning — Detected pivots are stored and automatically pruned according to InpPivotMemory (storage cap) and InpLookbackBars (lookback window).
- K-Means Clustering — Stored pivot prices are clustered via K-Means ( InpClusterCount clusters, InpKMeansIterations optimization passes), partitioning the price axis into statistical groups.
- Profile Construction — Within the InpLookbackBars window, pivots are binned at InpProfileBins resolution with InpBinSmoothing radius; the bin with the highest count is marked as the POC (Point of Control).
- ATR-Filtered S/R Lines — An ATR-based ( InpAtrPeriod × InpAtrMultiplier ) overlap threshold prevents excessively dense pivot lines; support (pivot low) and resistance (pivot high) reference lines are drawn and visually de-emphasized after a break.
Key Features
- Reversal Probability Profile (histogram) projected to the right of the chart; width controlled by InpProfileWidth , offset by InpProfileOffset
- POC marker with dominant cluster color highlight
- K-Means cluster center lines (dashed)
- ATR-filtered pivot support/resistance lines that automatically switch style upon break
- Optional pivot dots colored by cluster
- Optional bin text (probability % or raw count)
- Optional alerts (on POC touch or high-probability zone touch) — disabled by default
Main Input Parameters
Parameter | Description |
|---|---|
Pivot Left / Right Bars | Bars to the left / right for pivot confirmation |
Calculation Lookback | Number of bars used for calculation |
Stored Pivots Limit | Maximum number of pivots kept in memory |
Profile Resolution | Number of histogram bins |
Profile Clusters | K-Means cluster count |
Cluster Optimization Passes | K-Means iteration count |
ATR Period / Multiplier | ATR period and overlap-threshold multiplier |
High Probability Threshold | Alert threshold for high-probability zones (%) |
Appearance parameters (colors, transparency, line width, text mode, dot size, etc.) are all configurable under the "Appearance" input group.
Usage
- Place Inverseprobabilitydistribution.mq5 into MQL5/Indicators/ , compile, then drag onto a chart from the Navigator
- Adjust Pivot Left/Right Bars and ATR Multiplier according to the volatility of your instrument
- The profile appears on the right side of the chart — longer bars indicate higher historical pivot density at that price region
- The POC line marks the price level with the highest historical reversal density; support/resistance lines help identify potential price-reaction zones
- Observe extensively on a demo account before using for live-reference purposes
📌 Risk Disclosure: This indicator is a visualization of historical-price statistics only. It does not constitute investment advice and does not predict future price movement. A high pivot density does not guarantee that price will reverse. Users bear full responsibility for their trading decisions.
Compatible Instruments: All MT5 symbols — forex, CFDs, futures, indices.
Recommended Timeframes: 5-minute and above; very low timeframes may reduce readability due to pivot noise.
