OPEN-SOURCE SCRIPT
FVG with Probabilities | GainzAlgo

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 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:
Comprehensive Menu Inputs
FVG Detection & Displacement
IFVG Rules (The Flip Logic)
Signal Engine
Time-of-Day Filter
How to Use the Indicator
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:
- P/D Alignment (1.5x Weight): Checks if a long is in discount or a short is in premium relative to recent swing points.
- Market Structure (1.3x Weight): Alignment with a recent Break of Structure (BOS).
- Size/ATR Ratio (1.2x Weight): Gaps that are too small or excessively large relative to volatility are downgraded.
- Trend & HTF (1.0x Weight): Alignment with the 20/50 EMA stack and the 200 HTF EMA.
- Volatility Regime (0.9x Weight): Higher scores during expansion, reduced scores during compression.
- Volume (0.8x Weight): Uses Relative Volume (RVOL) to confirm institutional participation.
- 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.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Get GainzAlgo only at gainzalgo.com
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Get GainzAlgo only at gainzalgo.com
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน