OPEN-SOURCE SCRIPT

Fair Value Gap Marker

2 028
Fair Value Gap Marker

Overview

Fair Value Gap Marker is a configurable market imbalance visualization tool designed to automatically detect, evaluate, and manage Fair Value Gaps (FVGs) using a three-candle price imbalance model. While the Fair Value Gap concept is widely recognized in technical analysis, this implementation expands the basic detection model by introducing adaptive volatility filtering, quantitative strength scoring, multi-timeframe analysis, and automated zone lifecycle management.

The objective of the indicator is not to display every possible imbalance, but to help traders focus on higher-quality Fair Value Gaps by filtering insignificant gaps and providing additional contextual information about each detected zone.

---

What is a Fair Value Gap?

A Fair Value Gap represents a temporary market inefficiency created when price moves aggressively enough that little or no trading occurs within a specific price range.

Such rapid displacement can leave an imbalance between buyers and sellers. Many traders monitor these areas because price may revisit them later before continuing its trend or establishing a reversal.

Rather than manually inspecting charts for these imbalances, Fair Value Gap Marker continuously scans completed candles and automatically identifies qualifying bullish and bearish Fair Value Gaps.

---

# Detection Algorithm

The indicator evaluates every completed three-candle sequence.

A Bullish Fair Value Gap is identified when the current candle's low remains above the high of the candle two bars earlier.

A Bearish Fair Value Gap is identified when the current candle's high remains below the low of the candle two bars earlier.

Only confirmed candle data is evaluated, ensuring that detected Fair Value Gaps remain stable once created.

---

# Adaptive Minimum Gap Filtering

Not every Fair Value Gap has equal analytical value.

Very small gaps frequently occur during normal market fluctuations and may simply represent insignificant price noise.

To reduce unnecessary chart clutter, this indicator offers two independent filtering methods.

### Percentage Filter

The minimum acceptable gap size can be defined as a percentage of the current market price.

Only Fair Value Gaps exceeding the specified percentage threshold are displayed.

This mode is useful for traders who prefer a fixed proportional filter across different assets.

---

### ATR Adaptive Filter

The second filtering method compares the gap size against the current Average True Range (ATR).

Instead of relying on a fixed gap width, every imbalance must exceed a configurable multiple of current market volatility.

Because ATR expands during volatile conditions and contracts during quieter markets, this approach automatically adapts the minimum acceptable Fair Value Gap size without requiring constant manual adjustment.

This helps maintain more consistent filtering across different symbols, sessions, and market environments.

---

# Fair Value Gap Strength Score

One of the primary enhancements introduced in this implementation is the Fair Value Gap Strength Score.

Rather than assuming all detected imbalances have equal significance, every Fair Value Gap is assigned a numerical score ranging from 0 to 100.

The score combines two independent measurements.

## 1. Gap Size Analysis

The script compares the width of the Fair Value Gap with the current ATR.

Larger displacement moves generally indicate stronger directional momentum and therefore contribute more heavily to the final score.

---

## 2. Relative Volume Analysis

The volume of the candle responsible for creating the Fair Value Gap is compared against its recent moving average.

Higher-than-average participation suggests stronger market commitment and increases the confidence score.

---

## Final Strength Score

The final Strength Score blends volatility expansion and relative participation into a single numerical value.

Higher scores generally represent Fair Value Gaps created by stronger market displacement accompanied by relatively stronger trading activity.

Users may also define a minimum acceptable Strength Score, allowing weaker Fair Value Gaps to be filtered automatically.

This provides an additional quality layer beyond simple price imbalance detection.

---

# Multi-Timeframe Fair Value Gap Detection

The indicator supports optional Higher Timeframe (HTF) analysis.

When enabled, the script independently evaluates completed candles from the selected higher timeframe using the same Fair Value Gap detection algorithm.

Detected higher-timeframe Fair Value Gaps are projected directly onto the active chart using a dedicated color scheme.

This enables traders to monitor institutional imbalance zones from larger market structures while executing analysis on lower timeframes.

The higher-timeframe feature removes the need to switch between multiple charts during analysis.

---

# Automatic Zone Management

Each detected Fair Value Gap becomes an independent price zone.

Once created, every zone is continuously monitored as new market data becomes available.

Users may choose between two operating modes.

### Persistent Mode

Fair Value Gaps remain visible regardless of future price action.

This mode is useful for historical analysis.

---

### Automatic Mitigation Mode

When enabled, the script continuously checks whether price has fully traded back into the imbalance.

Once a Fair Value Gap has been completely mitigated, its corresponding zone is automatically removed from the chart.

This helps reduce clutter while keeping attention focused on active market inefficiencies.

---

# Dynamic Zone Extension

Every active Fair Value Gap extends forward automatically.

As new candles appear, existing zones continue projecting into future price action until mitigation occurs or the configured extension period expires.

This allows traders to monitor future interactions between price and previously identified imbalance zones without manually updating chart objects.

---

# Visualization

The indicator includes multiple visualization options.

Users may display:

• Bullish Fair Value Gaps

• Bearish Fair Value Gaps

• Higher-Timeframe Fair Value Gaps

Zones may use either fixed bullish/bearish colors or rotate through a customizable color palette, making consecutive imbalance zones easier to distinguish during periods of increased market activity.

Strength Scores may also be displayed directly inside each Fair Value Gap box.

---

# Available Settings

The indicator includes configurable options for:

• Bullish Fair Value Gap visibility

• Bearish Fair Value Gap visibility

• Percentage-based minimum gap filtering

• ATR-based adaptive filtering

• ATR Length

• ATR Multiplier

• Strength Score display

• Minimum Strength Score threshold

• Volume Average Length

• Multi-Timeframe detection

• Higher-Timeframe selection

• Automatic mitigation removal

• Zone extension length

• Fixed colors

• Palette cycling

• Complete visual customization

---

# Suggested Workflow

One possible workflow is:

1. Determine the primary market trend using your preferred methodology.

2. Enable Higher-Timeframe Fair Value Gap detection if broader market context is required.

3. Wait for new Fair Value Gaps that satisfy the selected filtering criteria.

4. Evaluate the Strength Score.

5. Monitor future price interaction with active imbalance zones.

6. Combine Fair Value Gap analysis with your own confirmation techniques such as market structure, liquidity sweeps, order blocks, break of structure (BOS), change of character (CHoCH), volume analysis, or personal risk management rules before making trading decisions.

The indicator intentionally does not generate automated buy or sell signals.

Its purpose is to provide an objective framework for identifying and monitoring price imbalance zones.

---

# Original Design Philosophy

This implementation was developed to extend the traditional Fair Value Gap workflow beyond simple imbalance detection.

Instead of displaying every possible gap, the indicator integrates multiple analytical layers—including adaptive ATR-based filtering, quantitative Strength Scoring, configurable minimum quality thresholds, automatic mitigation management, dynamic zone extension, and optional multi-timeframe confluence—to help traders organize Fair Value Gaps according to both market volatility and relative participation.

The design philosophy focuses on improving clarity, reducing low-quality signals, and providing a flexible analytical framework suitable for different trading styles and market conditions.

---

## Disclaimer

This indicator is an analytical charting tool designed to assist technical analysis.

It does not predict future price movement, guarantee profitable trades, or provide financial or investment advice.

Trading decisions should always be based on independent analysis, proper risk management, and the trader's own methodology.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.