Quant Probability Risk Neutral Density Scan Pair
- 指标
- 版本: 9.51
- 激活: 5
QuantEdge Probability Map Pro V1.4 - Technical Description & Operational Manual
1. OVERVIEW AND SYSTEM ARCHITECTURE
QuantEdge Probability Map Pro V1.4 is an institutional-grade quantitative analysis engine and real-time risk-neutral probability modeling system designed for MetaTrader 5. The software computes forward-looking price probability density functions (PDF), cumulative distribution functions (CDF), implied volatility surfaces, options Max Pain levels, statistical distribution moments (Mean, Mode, Skewness, Kurtosis), and At-The-Money (ATM) options Greeks. It provides multi-timeframe predictive price trajectory projections, 1-Sigma (68.2%) and 2-Sigma (95.4%) confidence bands, and an interactive multi-asset matrix scanner featuring instant click-to-switch chart navigation.
2. QUANTITATIVE AND MATHEMATICAL METHODOLOGY
The system integrates two complementary analytical engines: a primary Option Chain Risk-Neutral Density (RND) engine and an Adaptive Volatility Fallback engine.
2.1. Risk-Neutral Density (RND) & Breeden-Litzenberger Formulation
When external option chain data is provided, the indicator calculates the risk-neutral probability density function f(K) across strike prices K using the Breeden-Litzenberger theorem. The model proves that the probability density is directly proportional to the second partial derivative of European call option pricing functions C(K,T) with respect to strike price K:
f(K) = exp(r * T) * (d^2 C / dK^2)
Where r denotes the annualized risk-free interest rate and T represents the time to expiration expressed in annual fractions (DTE / 365.25).
2.2. Black-Scholes Implied Volatility Surface Solving
Raw option quotes are converted into mid-market prices: Mid = (Bid + Ask) / 2. To build a smooth volatility surface, the software extracts implied volatility (IV) for each valid strike using a hybrid numerical solver combining Newton-Raphson iteration and Bisection root-finding algorithms. The Black-Scholes pricing function C(S, K, T, r, q, sigma) is inverted until numerical convergence within 1e-6 tolerance:
C_BS = S * exp(-q * T) * N(d1) - K * exp(-r * T) * N(d2)
d1 = (ln(S / K) + (r - q + 0.5 * sigma^2) * T) / (sigma * sqrt(T))
d2 = d1 - sigma * sqrt(T)
Implied volatility values are bounded strictly between 0.01 (1%) and 4.0 (400%) to eliminate bad data quotes.
2.3. Natural Cubic Spline Interpolation Engine
To obtain a continuous call pricing function across arbitrary price levels, discrete strike IV points are interpolated using a Natural Cubic Spline model. The algorithm sets up a tridiagonal linear equation matrix solving for second derivatives (c_i) at each node under natural boundary conditions (c_0 = 0, c_n = 0). Spline coefficients (a_i, b_i, c_i, d_i) define smooth piecewise cubic polynomials S_i(x) = a_i + b_i*dx + c_i*dx^2 + d_i*dx^3, ensuring first and second derivative continuity across all grid points and preventing arbitrage violations.
2.4. Adaptive Volatility & Synthetic Fallback Engine
In the absence of external CSV option chain files or if data validation fails, the indicator automatically activates its Adaptive Synthetic Mode. This mode calculates dynamic expected volatility by analyzing high-frequency bar range structures and Average True Range (ATR) metrics over historical periods:
sigma = max(0.08, min(0.75, (AverageBarRange / SpotPrice) * 45.0))
The calculated volatility drives a synthetic log-normal probability density grid based on Black's forward model:
d = (ln(K / Spot) - (r - 0.5 * sigma^2) * T) / (sigma * sqrt(T))
PDF(K) = NormPDF(d) / (K * sigma * sqrt(T))
This guarantees operational continuity across standard Spot Forex pairs, Commodities, Stock Indices, and Crypto assets.
2.5. Statistical Moments & Higher-Order Diagnostics
The discrete probability distribution grid (configurable from 40 to 200 points) is evaluated to derive primary statistical metrics:
- Expected Mean: The probability-weighted average price across the RND curve: Mean = Sum(Price_i * Density_i * dK).
- Mode Price: The exact price level corresponding to peak probability density max(Density_i).
- Expected Move (1-Sigma): The standard deviation of the distribution: StdDev = sqrt(Sum((Price_i - Mean)^2 * Density_i * dK)).
- Skewness: Quantifies directional distribution asymmetry: Skew = Sum((Price_i - Mean)^3 * Density_i * dK) / StdDev^3. Negative skew indicates put demand and downside tail protection; positive skew indicates call demand.
- Excess Kurtosis: Measures tail risk relative to a Gaussian bell curve: Kurtosis = (Sum((Price_i - Mean)^4 * Density_i * dK) / StdDev^4) - 3.0.
- Quantile Mapping: Determines 1-Sigma (15.87th and 84.13th percentiles) and 2-Sigma (2.28th and 97.72nd percentiles) price levels via Cumulative Distribution Function (CDF) integration.
2.6. Option Max Pain Magnet Algorithm
The Max Pain algorithm identifies the underlying strike price at which option contract holders suffer maximum financial loss, representing an institutional price attraction zone near expiration. The engine evaluates total intrinsic payout loss across candidate prices:
TotalLoss(P) = Sum(max(0, P - K_i) * Volume_i [Calls]) + Sum(max(0, K_i - P) * Volume_i [Puts])
The price P minimizing TotalLoss(P) is designated as the Max Pain target level.
2.7. At-The-Money (ATM) Options Greeks Engine
Real-time mathematical analytical derivatives are evaluated for At-The-Money options:
- Call Delta: exp(-q * T) * N(d1)
- Put Delta: -exp(-q * T) * N(-d1)
- Gamma: exp(-q * T) * n(d1) / (Spot * sigma * sqrt(T))
- Vega: Spot * exp(-q * T) * n(d1) * sqrt(T) / 100
- Theta (Daily): (-(Spot * sigma * exp(-q * T) * n(d1)) / (2 * sqrt(T)) - r * Spot * exp(-r * T) * N(d2) + q * Spot * exp(-q * T) * N(d1)) / 365.25
2.8. Predictive Trajectory & Multi-Timeframe Projection Engine
The predictive trajectory feature constructs a non-repainting mathematical vector extending from bar zero open time to a target horizon time scaled to two higher timeframes (+2 TF). Target price calculation applies progress-factored square-root time scaling:
TargetPrice = Spot + (AnchorPrice - Spot) * sqrt(TargetSeconds / HorizonSeconds)
AnchorPrice dynamically combines Max Pain (50%), Mode (35%), and Mean (15%).
2.9. Signal Generation & Repaint Rules
- All histogram distributions, statistical levels, and dashboard metrics process closed historical bar data and live tick prices in real time.
- The Predictive Trajectory Trendline anchors strictly to historical bar zero timestamps and extends forward into future open chart space without altering past line coordinates (Non-Repainting).
- Terminal alerts trigger dynamically when live bid prices cross 2-Sigma extreme probability boundaries.
3. EXHAUSTIVE INPUT PARAMETERS MANUAL
3.1. Multi-Pair Scanner Watchlist
- InpScannerPairs (Default: "EURUSD,GBPUSD,USDJPY,XAUUSD") [string]: Comma-separated list of ticker symbol names for the multi-pair matrix scanner. The engine automatically matches base names with broker-specific suffixes or prefixes.
- InpDefaultTab (Default: TAB_SCANNER) [ENUM_DASH_TAB]: Defines the initial active view mode of the dashboard panel upon chart initialization. Options include TAB_ANALYTICS (Detailed Analytics View) and TAB_SCANNER (Multi-Pair Matrix Scanner).
3.2. Data Source Settings
- InpCSVFileName (Default: "option_chain.csv") [string]: Name of the option chain CSV file located inside the terminal's MQL5/Files directory.
- InpFilterExpiry (Default: "") [string]: Expiration date filter in YYYY.MM.DD format. Leaving this field blank automatically selects the nearest available option expiration date found in the file.
- InpRiskFreeRate (Default: 0.045) [double]: Annualized risk-free interest rate in decimal format (e.g., 0.045 represents 4.5% annual yield). Used in Black-Scholes and RND formulas.
- InpDividendYield (Default: 0.000) [double]: Annualized continuous dividend yield of the underlying asset in decimal format (e.g., 0.020 represents 2.0% annual yield).
- InpFilterMinVolume (Default: 0) [int]: Minimum contract volume threshold required for an option strike quote to be included in calculations. Setting to 0 processes all valid quotes.
3.3. Adaptive Multi-Timeframe Predictor
- InpDrawPredictor (Default: true) [bool]: Enables or disables visual rendering of the predictive trajectory trendline extending into future chart space.
- InpPredictorColor (Default: clrDeepPink) [color]: Color assigned to the predictive trajectory trendline.
- InpPredictorWidth (Default: 2) [int]: Line width in pixels for the predictive trajectory vector (supported range: 1 to 5 pixels).
3.4. Quantitative & Modeling
- InpGridPoints (Default: 100) [int]: Number of numerical integration points used for spline interpolation and density calculations. Bounded between 40 (fastest) and 200 (highest resolution).
- InpCustomTarget (Default: 0.0) [double]: Custom target price used to compute explicit Cumulative Distribution Function (CDF) probability (Prob Price >= Target). Setting 0.0 defaults target to current Spot price.
3.5. Visual Projections (Canvas Engine)
- InpDrawLevels (Default: true) [bool]: Toggles visual display of horizontal price lines for Mode, Mean, Max Pain, 1-Sigma, and 2-Sigma boundaries on the main chart window.
- InpDrawDensityHist (Default: true) [bool]: Toggles display of the right-aligned horizontal probability density profile histogram overlay.
- InpDrawForwardCone (Default: true) [bool]: Toggles rendering of the forward-looking 1-Sigma and 2-Sigma shaded probability expansion cone extending to the expiration date.
- InpDrawExpiryWall (Default: true) [bool]: Toggles display of the vertical dashed line marking the exact option expiration timestamp on the chart background.
- InpHistWidthPixels (Default: 250) [int]: Maximum horizontal visual width allocation for density histogram bars, measured in screen pixels.
- InpModeColor (Default: clrAqua) [color]: Line color for the Mode price level (peak RND density).
- InpMeanColor (Default: clrMediumSlateBlue) [color]: Line color for the Expected Mean price level.
- InpMaxPainColor (Default: clrMagenta) [color]: Line color for the option Max Pain price level.
- InpSD1Color (Default: clrGold) [color]: Line color for the 1-Sigma (68.2% probability interval) upper and lower boundary lines.
- InpSD2Color (Default: clrDarkOrange) [color]: Line color for the 2-Sigma (95.4% extreme probability interval) upper and lower boundary lines.
- InpHistBarColor (Default: C'35,100,180') [color]: Base RGB color for the probability density histogram bars.
- InpConeColor (Default: C'100,150,200') [color]: Base ARGB color used for shaded forward probability cone polygon fills.
3.6. Practical Trader Signals & Alerts
- InpEnableAlerts (Default: true) [bool]: Enables native MT5 terminal pop-up audio and dialog alerts when spot price breaches 2-Sigma boundaries.
- InpEnablePush (Default: false) [bool]: Enables mobile push notifications sent to registered iOS/Android MetaTrader mobile devices upon 2-Sigma extreme price events.
- InpAlertCooldownSec (Default: 300) [int]: Minimum cooldown period in seconds required between consecutive alert triggers to prevent notification spam.
3.7. Dashboard UI & Placement
- InpShowPanel (Default: true) [bool]: Toggles visibility of the interactive graphical dashboard panel.
- InpPanelBgColor (Default: C'12,15,20') [color]: Background fill color for the dashboard panel.
- InpTextColor (Default: C'210,215,225') [color]: Main font color for numerical metric labels inside the dashboard.
- InpAccentColor (Default: C'0,160,255') [color]: Color accent used for dashboard headers, primary highlights, and active tab highlights.
- InpPanelX (Default: 25) [int]: Initial horizontal X-coordinate offset distance in pixels from the top-left chart corner.
- InpPanelY (Default: 35) [int]: Initial vertical Y-coordinate offset distance in pixels from the top-left chart corner.
4. CSV DATA INTEGRATION & FILE STRUCTURE SPECIFICATION
To utilize option-derived RND modeling, place your option chain CSV file inside the MT5 terminal directory: MQL5/Files/option_chain.csv.
4.1. Mandatory CSV File Format Specification
The CSV file must contain comma-separated values adhering to the following structure:
Strike,Bid,Ask,Type,Expiry,Volume
1.0800,0.0120,0.0125,C,2026.12.18,1500
1.0800,0.0040,0.0045,P,2026.12.18,2100
1.0850,0.0080,0.0085,C,2026.12.18,3200
1.0850,0.0070,0.0075,P,2026.12.18,1800
4.2. CSV Data Requirements & Rules
- Column 1 (Strike): Option strike price in floating point decimal format.
- Column 2 (Bid): Best bid price for the option contract.
- Column 3 (Ask): Best ask price for the option contract.
- Column 4 (Type): Option type string ('C' or 'Call' for Calls; 'P' or 'Put' for Puts).
- Column 5 (Expiry): Expiration date formatted as YYYY.MM.DD or YYYY-MM-DD.
- Column 6 (Volume): Optional contract trading volume or open interest integer.
- The file must contain at least 4 valid strikes surrounding the current spot price. If option quotes deviate more than 20% from spot price, the data validator rejects the CSV file and activates Adaptive Synthetic Mode.
5. INTERPRETATION GUIDELINES & PRACTICAL APPLICATION
5.1. Confidence Intervals & Boundary Trading
- 1-Sigma Range (+/- 1 SD): Represents the 68.2% probability expected price containment zone at expiration. Prices remaining within 1-Sigma reflect normal market volatility conditions.
- 2-Sigma Range (+/- 2 SD): Represents the 95.4% statistical boundary. Price breaches beyond 2-Sigma indicate statistical tail events (Overbought or Oversold conditions) with high probability of mean-reversion toward Expected Mean or Mode levels.
5.2. Market Skewness & Sentiment Bias Diagnostics
- Bullish Skew (Skewness > +0.15): Indicates higher call option implied volatility relative to puts, reflecting upside sentiment bias and positive directional expectations.
- Bearish Hedge Skew (Skewness < -0.15): Indicates elevated put option implied volatility, reflecting institutional demand for downside tail risk hedging.
- Balanced Distribution (-0.15 <= Skewness <= +0.15): Indicates symmetric volatility distribution and neutral market sentiment.
5.3. Max Pain Pinning Dynamics
Option Max Pain identifies the price level where aggregate option open interest expires worthless. As option expiration dates approach (DTE < 5), underlying market prices frequently display magnet-like attraction toward Max Pain due to delta-hedging rebalancing by option market makers.
5.4. Options Structure Positioning Setups
- Iron Condor Range Boundaries: Calculated automatically as Mean +/- (1.5 * Expected Move). Provides optimal strike placement levels for neutral range-bound strategies.
- Target Probability Evaluation: Displays exact numerical probability percentage of price expiring at or above any user-selected custom price level.
6. DASHBOARD CONTROLS, SCANNER MATRIX & NAVIGATION
6.1. Multi-Pair Scanner Matrix Tab
- Live Table View: Displays watchlist symbols, real-time spot prices, directional statistical bias, calculated +2 TF target prices, and range status (IN RANGE, OVERBOUGHT, OVERSOLD).
- One-Click Symbol Switching: Clicking the interactive 'OPEN' button on any row triggers a chart event that instantly switches the current chart window to the selected symbol while maintaining template settings.
6.2. Detailed Analytics Tab
- Real-Time Numerical Metrics: Displays Spot Price, Mode Price, Expected Mean, Max Pain, 1-Sigma Expected Move (points and percentage), Target Price (+2 TF), ATM Greeks (Delta, Gamma, Vega, Theta), Iron Condor range, Skewness Bias, Expiry Target Date, and Calculation Status.
6.3. Direct Canvas Control Buttons
- LVL Button: Toggles horizontal level lines on/off.
- HIST Button: Toggles horizontal density histogram overlay on/off.
- CONE Button: Toggles forward probability cone fill on/off.
- PRED Button: Toggles predictive trajectory trendline on/off.
- RE-CALC Button: Forces immediate recalculation of math models, CSV re-parsing, and visual redrawing.
- [ - ] / [ + ] Button: Minimizes or expands the dashboard panel to preserve chart space.
- Panel Dragging: Click and hold the header bar to drag the dashboard panel to any location on the chart.
7. COMPUTATIONAL EFFICIENCY & SYSTEM PERFORMANCE
QuantEdge Probability Map Pro V1.4 is built for speed and resource efficiency:
- Canvas Bitmap Processing: Visual graphics use dynamic ARGB memory buffers managed by the CCanvas class. Screen redraws execute only during chart resize events or tick updates, avoiding thread stalling.
- Fast Spline Solving: The natural cubic spline solver uses a memory-preallocated tridiagonal matrix algorithm executing in O(N) linear time complexity.
- Intelligent Timer Execution: Heavy matrix updates execute on a controlled 3-second timer interval, while lightweight UI interactions run via event handlers to ensure minimal CPU load.
8. TECHNICAL DIAGNOSTICS & TROUBLESHOOTING FAQ
8.1. Dashboard Status Messages Explained
- "Calibrated (CSV Based)" [Green]: Option chain CSV file loaded, validated, and processed successfully via Breeden-Litzenberger RND formulation.
- "Adaptive Mode (No CSV)" [Yellow]: CSV file not found in MQL5/Files folder. System automatically switched to Adaptive Volatility fallback mode.
- "Adaptive (CSV Ignored/Invalid)" [Yellow]: CSV file found but failed validation (insufficient strikes, outdated dates, or strikes off by >20% from spot). System automatically activated Adaptive Volatility mode.
8.2. Frequently Asked Questions
Q: Can I run this indicator on instruments without option data?
A: Yes. The indicator automatically detects missing CSV files and activates Adaptive Synthetic Mode, deriving probability profiles from price range volatility.
Q: Does the predictive trajectory line repaint?
A: No. The trajectory line anchors to the historical bar zero timestamp and extends forward into future time space. Past line coordinates remain fixed.
Q: How do I load custom option chains?
A: Export option chain quotes into CSV format matching the 6-column structure detailed in Section 4, save as 'option_chain.csv' in the MQL5/Files folder, and click RE-CALC on the dashboard.
9. RISK DISCLAIMER
Trading foreign exchange, commodities, indices, and financial derivatives involves substantial risk of capital loss and is not suitable for all investors. Past performance and statistical models do not guarantee future market results. QuantEdge Probability Map Pro is a technical analysis software tool designed to assist traders in technical evaluation; it does not provide financial advice or guarantee trading profits. Users should thoroughly test the indicator on a demo account before live deployment.
