OPEN-SOURCE SCRIPT

FVG with Probabilities | GainzAlgo

53 301
FVG with Probabilities

The FVG Quality Engine v5.1 is a high-performance, institutional-grade toolkit specifically designed for the volatile nature of 0DTE options and lower-timeframe scalp trading.

Unlike standard gap detectors, this engine utilizes a complex scoring model to quantify the probability of a Fair Value Gap (FVG) holding or failing in real-time.

The Theory of the Fair Value Gap (FVG)

At its core, a Fair Value Gap represents a market imbalance. It is a three-candle sequence where price moves so rapidly that it leaves behind a structural void where only one side of the market was efficiently filled.
  • The Displacement: An FVG is only as strong as the energy behind it.
    This indicator requires displacement, meaning the candle must be large relative to volatility (ATR) and possess a solid body with minimal wicks.
  • The Rebalance Magnet: Price has a natural tendency to return to these imbalances to find fair value.
    The engine tracks the Consequent Encroachment (CE), or the 50% midpoint of the gap, which often serves as the most sensitive reaction level.
  • Inversion (IFVG): When price fails to respect an FVG and instead closes with displacement on the opposite side, the gap flips.
    A bullish FVG that is closed through becomes a bearish resistance zone, known as an Inversion FVG.

The Quality Scoring Model: Probabilities and Values

The indicator calculates a probability score for every gap (clamped between 4% and 85%) to help distinguish between low-quality noise and high-confluence setups. This is a weighted logit model based on eight key factors:
  1. P/D Alignment (1.5x Weight): Checks if a long is in discount or a short is in premium relative to recent swing points.
  2. Market Structure (1.3x Weight): Alignment with a recent Break of Structure (BOS).
  3. Size/ATR Ratio (1.2x Weight): Gaps that are too small or excessively large relative to volatility are downgraded.
  4. Trend & HTF (1.0x Weight): Alignment with the 20/50 EMA stack and the 200 HTF EMA.
  5. Volatility Regime (0.9x Weight): Higher scores during expansion, reduced scores during compression.
  6. Volume (0.8x Weight): Uses Relative Volume (RVOL) to confirm institutional participation.
  7. Killzones (0.7x Weight): Gaps formed during London or New York sessions receive a boost.

Comprehensive Menu Inputs

FVG Detection & Displacement
  • Min FVG Size (ATR x): Controls sensitivity. Default of 0.3 ATR ensures meaningful gaps only.
  • Require Displacement: Middle candle must meet a minimum body-to-range ratio (default 0.6).

IFVG Rules (The Flip Logic)
  • Track IFVGs: Enables conversion of failed gaps into inversion zones.
  • Min Close Dist: Requires price to close at least 0.3 ATR beyond the gap.
  • Req Aligned BOS: Strict filter requiring a structural break for IFVG validation.

Signal Engine
  • Signal Mode
    Choose between Trend Only, Reversal Only, or Both.
  • Require Confirmation: Waits for opposing displacement after FVG/OB/Sweep interaction.
  • Trigger on CE Tap: Signals when price taps the 50% level of a high-quality FVG.

Time-of-Day Filter
  • Skip First/Last N Minutes: Avoids open volatility and end-of-day noise.
  • Skip Lunch: Filters out low-volume periods between 11:30 and 13:30 NY time.

How to Use the Indicator
  • Step 1: Identify the Bias: Use the dashboard to determine if the setup is trend or reversal. Look for EMA alignment: 20 EMA above 50 EMA and price above 200 EMA.
  • Step 2: Filter by Quality: Focus only on gaps labeled H (High) or M (Medium). High-quality gaps (>65%) indicate strong confluence.
  • Step 3: Entry Confluence: The best entries occur at A+ tier setups. These happen when price retests a high-scoring FVG or OB within a killzone and is followed by confirmation.
  • Step 4: Managing Inversions: If a bullish gap fails, do not ignore it. Watch for it to flip into a purple IFVG, acting as resistance for potential reversal or continuation.

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.