OPEN-SOURCE SCRIPT

FVG Quality Scorer | Flux Charts

12 188
GENERAL OVERVIEW:
FVG Quality Scorer is a Fair Value Gap analysis tool designed to extend beyond basic gap detection. Instead of treating every gap equally, this indicator evaluates each FVG across four independent scoring axes and assigns a letter grade (A through D) based on configurable thresholds. This creates a structured view of the chart where gaps are organized by their relative characteristics.

Every FVG is scored once at the moment of creation across Displacement Strength, Volume Delta, Contextual Location, and Structural Alignment. Each axis is scored from 0 to 25, producing a weighted composite score out of 100. Scores are fixed at creation, ensuring the evaluation reflects the conditions present at the time of formation and does not change retroactively. In contrast, each FVG’s lifecycle state (Fresh, Tested, Partially Filled, Mitigated) updates in real time as price interacts with the zone, providing a current view of how price is interacting with each gap.

A companion dashboard tracks grade distribution, active counts, total formations, and average fill times across the visible chart history. Score labels at the edge of each FVG box provide a quick reference to the assigned grade, with optional tooltips displaying the full scoring breakdown and current lifecycle state.

ảnh chụp nhanh [Screenshot: Wide chart view showing multiple FVG boxes with different grades visible, score labels on right edges, and the dashboard in the top right corner. Show a mix of bullish and bearish FVGs across different lifecycle states.]

FEATURES:
◇ Four-axis scoring system: Displacement Strength, Volume Delta, Contextual Location, and Structural Alignment, each scored from 0 to 25 for a maximum composite score of 100
◇ Letter grade assignment (A, B, C, D) using per-axis threshold gates with configurable minimum scores and required axes per grade
◇ Lower timeframe volume delta analysis using intrabar data to estimate directional volume distribution within the displacement candle
◇ Higher timeframe FVG nesting detection to identify when current timeframe gaps are positioned within higher timeframe imbalances
◇ Session timing reference covering Asian, London, New York AM, and New York PM sessions based on New York time
◇ Premium and Discount zone scoring using a proportional gradient based on the FVG’s position within a defined price range
◇ Market structure classification using swing high and swing low sequences to label conditions as bullish, bearish, or mixed
◇ Break of Structure (BOS) tracking using crossover logic to identify recent structural breaks relative to the FVG direction
◇ Post-sweep proximity detection identifying FVGs that form after a liquidity sweep of a swing level
◇ Lifecycle state tracking: Fresh → Tested → Partially Filled → Mitigated, with corresponding visual updates on the chart
◇ Score labels with optional tooltips displaying axis scores and current lifecycle state
◇ Dashboard displaying active counts, total formations, and average bars to mitigation per grade, along with nearest A-grade distance tracking
◇ Configurable axis weights for adjusting the influence of each scoring dimension in the composite score
◇ Alerts for newly formed A-grade and B-grade FVGs based on defined grading criteria

WHAT IS A FAIR VALUE GAP?
A Fair Value Gap is a three-candle price formation that highlights an imbalance in price movement. It occurs when the third candle’s wick does not overlap with the first candle’s wick, leaving a visible gap created by the middle candle. This middle candle is often referred to as the “displacement” candle, as it reflects a relatively strong move in price over a short period.
In a bullish FVG, the low of the third candle is positioned above the high of the first candle. In a bearish FVG, the high of the third candle is positioned below the low of the first candle. The space between these two wicks defines the FVG zone.

Within ICT and Smart Money Concepts frameworks, these gaps are interpreted as areas where price moved quickly, leaving limited trading activity at certain levels. As a result, these zones are often monitored as areas of interest if price revisits them in the future. However, not all FVGs share the same characteristics, and variations in formation context are what this indicator evaluates using its scoring system.

ảnh chụp nhanh [Screenshot: Annotated chart showing a textbook bullish FVG formation.]

WHAT IS THE THEORY BEHIND THIS INDICATOR?
The core premise behind FVG Quality Scorer is that gap detection alone does not capture the full context of how Fair Value Gaps form. On any given trading day, multiple FVGs can appear across timeframes, each with different characteristics depending on the surrounding price action. This indicator evaluates those characteristics using a structured scoring approach.

Not all FVGs form under the same conditions. For example, a gap created by a relatively small candle during low volume periods in a ranging market will differ in structure from one formed during a strong displacement move with increased volume, aligned with broader market structure and session timing. These differences are often considered when analyzing FVGs, but evaluating them manually across multiple factors and timeframes can be time intensive and subjective. FVG Quality Scorer standardizes this process by quantifying these characteristics into a consistent framework.

The indicator’s four-axis model reflects commonly used analytical considerations within ICT and Smart Money Concepts methodologies. These include measuring displacement strength, assessing volume characteristics, evaluating contextual positioning within a range or session, and identifying alignment with market structure. By organizing these factors into a rule-based system, the indicator provides a consistent method for comparing FVG formations based on their underlying attributes.

ảnh chụp nhanh [Screenshot: Zoomed in on a strong displacement candle forming a bullish FVG. ]

Axis 1: Displacement Strength (0 to 25 points)
The displacement candle is the middle candle of the three-bar FVG formation and is the candle responsible for creating the gap. This axis evaluates the characteristics of that candle based on its size, structure, and relation to surrounding price action. Candles with larger bodies relative to their total range, higher relative size compared to recent volatility, and alignment with neighboring candles are scored differently than candles with smaller bodies or more pronounced wicks.

The indicator evaluates three sub-metrics within this axis. Body-to-range ratio (0 to 10 points) measures how much of the candle’s total range is composed of the body versus the wicks. A ratio of 0.85 or higher receives 10 points, ratios between 0.70 and 0.85 receive 7 points, ratios between 0.55 and 0.70 receive 4 points, and anything below 0.55 receives zero.
ATR multiple (0 to 10 points) compares the displacement candle’s total range to the 14-period Average True Range. A range equal to or greater than 2 times the ATR receives 10 points, 1.5x to 2x receives 7 points, 1x to 1.5x receives 4 points, and values below 1x receive zero.
Consecutive displacement (0 to 5 points) evaluates whether the candles immediately before and after the displacement candle close in the same direction as the FVG. If both surrounding candles align, the FVG receives 5 points. If one aligns, it receives 2 points. If neither aligns, it receives zero. This metric reflects the consistency of direction across the three-candle formation.

ảnh chụp nhanh [Screenshot: Chart showing a high scoring A grade FVG with the tooltip visible, displaying the full axis breakdown.]

Axis 2: Volume Delta (0 to 25 points)
Volume reflects how much activity occurred, while volume delta separates that activity into directional components based on price movement. By analyzing lower timeframe data, volume can be divided into buying and selling activity within the displacement candle, providing additional context on how volume was distributed during the move.
The indicator uses lower timeframe intrabar data (configurable, default 1 minute) to estimate this distribution. Each lower timeframe candle within the displacement bar is classified as bullish volume (close above open) or bearish volume (close at or below open), and these values are aggregated to form a directional breakdown.

This axis evaluates three sub-metrics. LTF dominance (0 to 12 points) measures the percentage of total volume on the displacement candle that aligns with the FVG direction. Values above 75% receive 12 points, 60% to 75% receive 8 points, 50% to 60% receive 4 points, and values below 50% receive zero.

Relative volume (0 to 8 points) compares the displacement candle’s volume to the 20-period volume average. Volume equal to or greater than 2 times the average receives 8 points, 1.5x to 2x receives 5 points, 1x to 1.5x receives 2 points, and values below the average receive zero.
Volume rising (0 to 5 points) evaluates whether volume increases across the three candles of the formation, where volume on the displacement candle exceeds the prior candle, and the prior candle exceeds the one before it. This metric captures the progression of volume across the formation.

ảnh chụp nhanh Screenshot: Zoomed view showing the Delta volume panel below with visible volume spike on the displacement candle]

Axis 3: Contextual Location (0 to 25 points)
The location of an FVG within the recent price range provides additional context for how it formed. In ICT methodology, the range is often divided into two halves using the equilibrium (50%) level. The lower half is referred to as the “discount zone,” while the upper half is referred to as the “premium zone.”

A bullish FVG forming in the lower portion of the range is positioned within the discount zone, while a bearish FVG forming in the upper portion is positioned within the premium zone. FVGs that form closer to the midpoint or on the opposite side of the range can be described as having different contextual positioning relative to the defined range.

This indicator incorporates that positioning into its scoring by evaluating where the FVG forms within the selected lookback range, using a proportional approach rather than a fixed cutoff at the midpoint.

ảnh chụp nhanh [Screenshot: Premium & Discount Zones]
In addition to premium and discount positioning, other contextual factors can be used to describe how an FVG forms within the broader price environment. These include whether the FVG appears after a liquidity sweep, whether it is positioned within a higher timeframe FVG, and whether it forms during specific session windows. These elements provide additional structure for evaluating the formation context.

This axis evaluates four sub-metrics. Premium and Discount scoring (0 to 8 points) uses a proportional gradient across the recent price range defined by the Range Lookback setting. For bullish FVGs, gaps forming in the lower half of the range (below equilibrium) receive the full 8 points. Gaps forming above equilibrium receive a reduced score that decreases progressively as the FVG approaches the top of the range. The same logic is applied in reverse for bearish FVGs.
HTF FVG nesting (0 to 8 points) evaluates whether the current FVG is fully contained within a higher timeframe FVG of the same direction. The indicator retrieves higher timeframe data using the configurable HTF input and checks for this containment condition.

Post-sweep proximity (0 to 5 points) evaluates whether a swing level was exceeded shortly before the FVG formed. A sweep is defined as price moving beyond a swing high or swing low and then returning back within the prior range. This metric checks for that condition within a configurable lookback window.

Killzone timing (0 to 4 points) evaluates whether the FVG forms during predefined session windows. The indicator converts bar time to New York time and checks against four intervals: Asian session (20:00 to 00:00), London session (02:00 to 05:00), New York AM (09:30 to 11:00), and New York PM (13:30 to 16:00).

ảnh chụp nhanh [Screenshot: Chart showing an FVG forming in the premium zone (upper half of recent range) ]

Axis 4: Structural Alignment (0 to 25 points)
Market structure provides a framework for describing how price is evolving over time. This axis evaluates how the direction of an FVG relates to the current structure defined by swing highs and swing lows.

The indicator identifies swing highs and swing lows using pivot detection with a configurable swing length and evaluates three sub-metrics. Market structure classification (0 to 10 points) compares the most recent swing highs and swing lows to determine whether price is forming higher highs and higher lows, lower highs and lower lows, or a mixed sequence. These conditions are labeled as bullish, bearish, or mixed. Scoring is then assigned based on the relationship between the FVG direction and the identified structure.

EMA alignment (0 to 8 points) evaluates the position of price relative to a configurable Exponential Moving Average (default 50 period). For bullish FVGs, higher scores are assigned when price is positioned above the EMA, while for bearish FVGs, higher scores are assigned when price is positioned below the EMA. Scores are reduced when price is positioned on the opposite side relative to the FVG direction.

Recent BOS detection (0 to 7 points) evaluates whether a Break of Structure (BOS) has occurred within a configurable lookback window (default 20 bars). A BOS is defined as price closing beyond a recent swing high or swing low. The indicator uses crossover logic to identify these events and ensures each structural break is only counted once. Scoring is based on whether a recent BOS aligns with, differs from, or is absent relative to the FVG direction.

ảnh chụp nhanh Screenshot: Showing BoS and HH

Grade Assignment System
Instead of using a single composite score cutoff, FVG Quality Scorer applies a per-axis threshold system for grade assignment. For each grade level (A, B, C), you can define which axes are required and the minimum score each must meet. An FVG must satisfy all required axis thresholds to be assigned a given grade. This structure ensures that each selected dimension is evaluated independently rather than relying on a single averaged value.

For example, with default settings, an A grade requires all four axes to meet a minimum score of 12 out of 25. A B grade requires only the Displacement and Volume axes to meet a minimum of 12, while a C grade requires those same axes to meet a minimum of 8. Any FVG that does not meet the criteria for A, B, or C is assigned a D grade. These thresholds and required axes can be fully customized for each grade level.

A weighted composite score (0 to 100) is also calculated and displayed in the score label tooltip for reference, but it does not determine the assigned grade. This allows the grading system to operate independently of the composite value. The composite score uses configurable axis weights (default 25 per axis), which can be adjusted to modify how each dimension contributes to the total score.

ảnh chụp nhanh [Screenshot: Show multiple FVGs with different grades side by side]

Lifecycle State Machine
Each FVG is tracked through a series of lifecycle states as price interacts with the zone, and these transitions occur automatically regardless of grade. The lifecycle begins at Fresh when the FVG forms and no candle has interacted with the zone boundary. When price first wicks into the boundary (detected using crossover logic that excludes the formation candle), the state transitions to Tested.

If price closes within the zone, the state changes to Partially Filled, and the visual appearance of the box is adjusted to reflect this state. If price later closes back outside the zone, the state returns to Tested rather than Fresh, as the zone has already been interacted with. When price fully crosses through the zone, the FVG is marked as Mitigated. The definition of mitigation can be configured to require either a wick crossing or a full candle close beyond the zone.

Mitigated FVGs can either be removed from the chart or remain visible as dimmed boxes using the Show Historic setting. When mitigation occurs, the right edge of the box is fixed at the candle where the event took place. The current lifecycle state is displayed in the tooltip alongside the scoring breakdown when hovering over the score label.

ảnh chụp nhanh [Screenshot: Chart showing FVGs in different lifecycle states on the same view.]

🔹 Dashboard
The dashboard provides a statistical summary of FVG activity across the visible chart history. It is structured as a table with one row per grade (A through D) and three data columns. The Active column displays the number of unmitigated FVGs currently present on the chart for each grade. The Total column shows the total number of FVGs formed for each grade across the chart history. The Avg Fill Time column displays the average number of bars between formation and mitigation for FVGs of that grade that have been fully mitigated. This calculation includes only completed (mitigated) FVGs.

A bottom row in the dashboard tracks the nearest active A-grade FVG relative to the current price. It displays the distance from the current close to the nearest boundary of the zone (the lower boundary if the FVG is above price, or the upper boundary if below), along with a directional indicator. If price is currently within an A-grade zone, the dashboard displays “Inside zone.” If no A-grade FVGs are active, it displays “None active.” The dashboard position and text size can be configured.

ảnh chụp nhanh Screenshot: Close up of the dashboard table showing all four grade rows with Active, Total, and Avg Fill Time populated. Include the Nearest A row showing a directional arrow with distance.

🔹 Score Labels and Tooltips
Each FVG box displays its grade letter (A, B, C, or D) centered inside the zone. At the right edge of the box, a small label shows the composite quality score out of 100. Hovering over this label reveals a detailed tooltip with the complete scoring breakdown: the total score, the grade, individual scores for all four axes (each out of 25), and the current lifecycle state. This gives you instant access to why a particular FVG earned its grade without needing to open any settings. Score labels can be toggled off using the Show Score Labels setting if you prefer a cleaner chart.

INPUTS:
🔹 Settings
◇ Swing Length: Lookback period for pivot high and pivot low detection used in market structure analysis, BOS tracking, and sweep detection. Higher values produce fewer, more significant swing points. Default 5.
◇ ATR Length: Period for the Average True Range calculation used in displacement scoring. Default 14.
◇ LTF for Volume Delta: Lower timeframe used to calculate intrabar volume delta on the displacement candle. Default 1 minute. Must be lower than the chart timeframe for accurate results.
◇ HTF for FVG Nesting: Higher timeframe checked for FVG nesting confluence. Default 60 minutes (1 hour). Should be higher than the chart timeframe.
◇ Range Lookback: Number of bars used to calculate the premium and discount range for contextual scoring. Default 50.
◇ Sweep Proximity Window: Number of bars to look back for recent liquidity sweeps when scoring post sweep proximity. Default 5.
◇ BOS/CHoCH Lookback: Maximum number of bars a Break of Structure can be from the current bar and still be considered "recent" for structural scoring. Default 20.
◇ EMA Length: Period for the Exponential Moving Average used in structural alignment scoring. Default 50.
◇ Mitigation Method: Determines how FVG invalidation is measured. Wick mode triggers mitigation when a wick crosses through the zone. Close mode requires a candle close beyond the zone. Default Wick.
ảnh chụp nhanh Screenshot of the Settings input group in TradingView showing all the configurable parameters: Swing Length, ATR Length, LTF, HTF, Range Lookback, Sweep Window, BOS Lookback, EMA Length, and Mitigation Method.

🔹 Axis Weights
◇ Displacement Weight: Relative weight applied to the Displacement Strength axis when calculating the composite score displayed in the tooltip. Higher weight increases this axis's influence on the total score. Default 25.
◇ Volume Delta Weight: Relative weight for the Volume Delta axis. Default 25.
◇ Contextual Weight: Relative weight for the Contextual Location axis. Default 25.
◇ Structural Weight: Relative weight for the Structural Alignment axis. Default 25.

🔹 Display
◇ Minimum Display Grade: Hides FVGs below this grade threshold from the chart. Set to D to show all grades, or A to show only the highest quality gaps. Default C.
◇ Show Historic (Mitigated): When enabled, mitigated FVGs remain visible as grayed out boxes instead of being removed from the chart. Useful for studying how different grade levels performed historically. Default off.
◇ Show Score Labels: Toggles the score labels at the right edge of each FVG box. Hover over the label to see the full axis breakdown tooltip. Default on.
◇ Grade Colors (A → D): Four color pickers on a single row controlling the color for each grade tier. Defaults are green (A), teal (B), amber (C), and gray (D).

🔹 Dashboard
◇ Show Dashboard: Toggles the statistics dashboard on or off. Default on.
◇ Dashboard Position: Choose from all nine screen positions (top, middle, bottom combined with left, center, right). Default Top Right.
◇ Dashboard Size: Controls the text size of the dashboard. Options are Tiny, Small, Normal, and Large. Default Small.

🔹 A Grade / B Grade / C Grade
◇ Each grade tier has its own settings group with four minimum score thresholds (one per axis, 0 to 25) and four toggle switches to select which axes are required for that grade. An FVG must meet or exceed the minimum score on every required axis to earn the grade. Grades are checked top down: A first, then B, then C. Any FVG that fails all three checks receives a D grade. Unchecking a required axis means that axis is ignored for that grade's evaluation, allowing you to create grade profiles that focus on specific quality dimensions.
ảnh chụp nhanh Screenshot of the settings panel showing the A Grade, and B Grade input groups with their min score thresholds and require toggles visible.

ALERTS:
◇ New A Grade FVG: Fires when a new Fair Value Gap is detected that meets all A grade requirements. Use this to get notified of the highest quality setups without watching the chart continuously.
◇ New B Grade FVG: Fires when a new Fair Value Gap is detected that meets B grade requirements but does not qualify for A grade.

UNIQUENESS:
Many FVG indicators on TradingView focus on detecting gaps and may include basic filtering based on size or direction. FVG Quality Scorer extends this approach by evaluating each gap across multiple dimensions, including lower timeframe volume distribution, higher timeframe positioning, market structure classification, and session-based context. These factors are combined into a structured scoring framework.

The axis-based grading system provides an alternative to single-threshold scoring methods. Instead of relying on a single composite cutoff, each grade level is determined by minimum requirements across selected axes. This ensures that each specified dimension meets defined criteria rather than being offset by higher values in other areas.

The lifecycle state system tracks how each FVG evolves as price interacts with the zone, while the dashboard aggregates metrics such as counts and average bars to mitigation across grade levels. These features provide a structured way to review how FVGs have behaved over the selected chart history and to adjust grading configurations accordingly.

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.