OPEN-SOURCE SCRIPT
Updated

FVG Size

598
FVG Size Indicator – Description
Overview
This Pine Script v5 indicator detects and visualizes Fair Value Gaps (FVGs) on the chart. It draws colored boxes for FVGs, center lines (CE), and displays the size of each FVG as a label. The indicator is designed for manual analysis, helping traders identify potential price imbalances.

Key Features


FVG Detection:

Identifies bullish and bearish FVGs based on price structure.
Draws colored boxes for FVGs and dotted center lines (CE).



FVG Size Display:

Shows the size of each FVG as a label inside the box.
Customizable minimum size threshold to filter out smaller FVGs.



Dynamic Adjustments:

Extends FVG boxes to the right as new bars form.
Removes FVGs that are filled (mitigated) by price action.



Customizable Settings:

Adjustable colors, text size, and display options.




Settings and Translations
Here are the German settings with their English translations:
FVG Settings

Long FVG Farbe → Long FVG Color (Color for bullish FVG boxes)
Short FVG Farbe → Short FVG Color (Color for bearish FVG boxes)
CE Farbe → CE Color (Color for the center line)
Tage Rückblick → Lookback Days (Number of days to look back for FVGs)
Lösche gefüllte Boxen & Linien → Delete Filled Boxes & Lines (Removes FVGs that have been filled by price)

FVG Display

FVG Größe anzeigen → Show FVG Size (Displays the size of each FVG as a label)
Text → Text Size (Size of the FVG size label text)
Mindestgröße → Minimum Size (Minimum FVG size to display, filtering out smaller FVGs)


How It Works


FVG Detection Logic:

A bullish FVG is detected if the high of the 3rd bar is lower than the low of the 1st bar.
A bearish FVG is detected if the low of the 3rd bar is higher than the high of the 1st bar.



Drawing FVGs:

The indicator draws a box between the high/low of the 1st and 3rd bars.
A center line (CE) is drawn at the midpoint of the FVG.
The size of the FVG is displayed as a label inside the box.



Dynamic Adjustments:

FVG boxes are extended to the right as new bars form.
If the price fills the FVG, the box and line are removed (depending on settings).



Mitigation Logic:

If the price closes beyond the FVG boundaries, the FVG is considered "filled" and removed.
Release Notes
FVG Size Indicator – Description (English)

Changelog
10/04/2025 – Version 4.10.25 (Bugfix)
Fixed: CE lines were incorrectly appearing on non-FVG candles. Now, CE lines are only drawn on valid FVG candles.


Overview
This Pine Script v6 indicator detects and visualizes Fair Value Gaps (FVGs) on the chart. It draws colored boxes for FVGs, center lines (CE), and displays the size of each FVG as a label. The indicator is designed for manual analysis, helping traders identify potential price imbalances.


++++ New in Version 6 ++++
Fixed Bug: In the previous version, CE lines (Center Lines) were incorrectly drawn on candles that did not have an FVG. This bug has been fixed, so CE lines now only appear on actual FVG candles.


Key Features

FVG Detection:
Identifies bullish and bearish FVGs based on price structure.
Draws colored boxes for FVGs and dotted center lines (CE).


FVG Size Display:
Shows the size of each FVG as a label inside the box.
Customizable minimum size threshold to filter out smaller FVGs.


Dynamic Adjustments:
Extends FVG boxes to the right as new bars form.
Removes FVGs that are filled (mitigated) by price action.


Customizable Settings:
Adjustable colors, text size, and display options.


Settings and Translations
Long FVG Farbe: Color for bullish FVG boxes (Long FVG Color).
Short FVG Farbe: Color for bearish FVG boxes (Short FVG Color).
CE Farbe: Color for the center line (CE Color).
Tage Rückblick: Number of days to look back for FVGs (Lookback Days).
Lösche gefüllte Boxen & Linien: Removes FVGs that have been filled by price (Delete Filled Boxes & Lines).
FVG Größe anzeigen: Displays the size of each FVG as a label (Show FVG Size).
Text: Size of the FVG size label text (Text Size).
Mindestgröße: Minimum FVG size to display, filtering out smaller FVGs (Minimum Size).

How It Works

FVG Detection Logic:
A bullish FVG is detected if the high of the 3rd bar is lower than the low of the 1st bar.
A bearish FVG is detected if the low of the 3rd bar is higher than the high of the 1st bar.


Drawing FVGs:
The indicator draws a box between the high/low of the 1st and 3rd bars.
A center line (CE) is drawn at the midpoint of the FVG.
The size of the FVG is displayed as a label inside the box.


Dynamic Adjustments:
FVG boxes are extended to the right as new bars form.
If the price fills the FVG, the box and line are removed (depending on settings).


Mitigation Logic:
If the price closes beyond the FVG boundaries, the FVG is considered "filled" and removed.
Release Notes
FVG Size Indicator – Version 7 (Bugfix of Previous Bugfix)

04/11/2025 – Version 7
In Version 6, a bug was fixed where CE lines (Center Lines) appeared on candles without valid FVGs.
However, that fix itself was incomplete: in some cases, CE lines did not appear on all valid FVG boxes or disappeared too early.
Version 7 corrects that faulty fix. CE lines are now displayed reliably and exclusively inside valid FVG boxes, and are properly removed once the FVG is mitigated.

Overview

This Pine Script v6 indicator detects and visualizes Fair Value Gaps (FVGs) on the chart.
It draws colored boxes for FVGs, adds a dotted center line (CE), and displays the size of each FVG as a label.
The indicator is designed for manual analysis, helping traders identify potential price imbalances.

New and Corrected Features

Bugfix of previous bugfix – fixes the issue from Version 6 where CE lines were incomplete or incorrectly displayed.
CE lines now appear reliably and only inside valid FVG boxes.
Improved synchronization between boxes and lines during extension or removal.
General code optimization and better performance.

Key Features

FVG Detection – identifies bullish and bearish FVGs based on price structure.
Draws colored boxes and dotted center lines (CE).

FVG Size Display – shows the size of each FVG as a label inside the box.
Customizable minimum size threshold to filter out small gaps.

Dynamic Adjustments – boxes and lines automatically extend to the right as long as the gap remains open.
When the gap is filled, both the box and the line are automatically removed.

Customizable Settings – adjustable colors, text size, and display options.

Settings and Translations

FVG Einstellungen / FVG Settings (Main section for FVG configuration)
Long FVG Farbe / Long FVG Color (Color for bullish FVG boxes)
Short FVG Farbe / Short FVG Color (Color for bearish FVG boxes)
CE Linie / CE Line Color (Color for the dotted center line)
Rückblick / Lookback Days (Number of days to look back for FVGs)
Lösche gefüllte / Delete Filled (Automatically removes filled / mitigated FVG boxes)

FVG Anzeige / FVG Display (Display and visualization options)
FVG Größe anzeigen / Show FVG Size (Displays the size of each FVG as a label inside the box)
Text / Text Size (Font size of the FVG size label)
Mindestgröße / Minimum Size (Minimum FVG size to display)
Textfarbe / Text Color (Color of the label text)
Transparenz / Transparency (Transparency of the FVG boxes, 0 = opaque / 100 = invisible)

How It Works

FVG Detection Logic – a bullish FVG occurs when the high of the 3rd candle is lower than the low of the 1st candle.
A bearish FVG occurs when the low of the 3rd candle is higher than the high of the 1st candle.

Drawing FVGs – the indicator draws a box between the highs / lows of the 1st and 3rd candles.
A dotted CE line is placed at the midpoint of the box.
The size of the FVG is displayed as a label inside the box.

Dynamic Extension and Removal – boxes and lines extend automatically as long as the FVG remains open.
When price fills the FVG (mitigation), the box and CE line are removed (or hidden, depending on user settings).

Mitigation Logic

If the price closes beyond the FVG boundaries (above for bullish, below for bearish), the FVG is considered “filled” and is removed.

Disclaimer

This script is for analysis and educational purposes only and does not constitute financial, investment, or trading advice.
Use at your own risk.
Release Notes
FVG Size Indicator – Version 8
Mitigation Upgrade & Tick Threshold

New in Version 8

1. Extended Mitigation Logic
You can now choose how an FVG is considered “filled.”
Two methods are available:

CE Touch: The FVG is removed once price reaches the midpoint (CE) of the gap.

Full Close: An FVG is removed only when any candle closes fully above the FVG (bullish) or fully below the FVG (bearish).
Where the candle starts does not matter — the close is what counts.

2. Tick Threshold for Full Close
Full Close can be combined with a configurable tick tolerance.
This allows an FVG to be treated as closed even if the candle closes slightly inside the gap, within a defined number of ticks from the boundary.
This helps avoid situations where gaps remain on the chart due to very small differences in price.

3. Maximum Number of Visible FVGs
You can now set how many FVG boxes may appear on the chart at once.
When this limit is reached, the indicator automatically removes the oldest FVGs.
This keeps the chart cleaner and improves performance.

4. Improved Internal Consistency
The link between FVG boxes and CE lines has been strengthened.
FVGs are removed more reliably based on the selected mitigation mode.
Extensions and updates to boxes and lines behave more consistently compared to earlier versions.

Settings and Their Meanings (German → English)
Mitigation Art – Mitigation Mode
Chooses between CE Touch or Full Close.

Tick-Schwellwert (Full Close) – Tick Buffer (Full Close)
Number of ticks allowed between the close and the FVG boundary for Full Close.

Max. sichtbare FVGs – Max Visible FVGs
Defines how many FVGs may appear on the chart simultaneously.

Long FVG Farbe – Long FVG Color
Color of bullish FVG boxes.

Short FVG Farbe – Short FVG Color
Color of bearish FVG boxes.

CE Farbe – CE Color
Color of the dotted center line.

Rückblick – Lookback Days
Days used for scanning past candles for FVGs.

Lösche gefüllte – Delete Filled
Automatically removes FVGs once they are mitigated.

FVG Größe anzeigen – Show FVG Size
Displays the size of each FVG as a text label.

Text – Text Size
Font size of the FVG size label.

Mindestgröße – Minimum Size
Minimum size required for an FVG to be shown.

Textfarbe – Text Color
Color of the label text.

Transparenz – Transparency
Transparency level of FVG boxes.

How Full Close Works:
A bullish FVG is closed when the candle’s closing price is above the top boundary of the gap, or close enough to it according to the tick buffer.
A bearish FVG is closed when the closing price falls below the lower boundary, or within the defined tick tolerance.
Only the candle close is taken into account — wicks and the opening price do not matter.

Summary:
- New selectable mitigation mode: CE Touch or Full Close
- Full Close enhanced with an optional tick threshold
- Option to limit the number of visible FVGs
- More stable extension and removal of FVG boxes
- Improved internal behavior and consistency
Release Notes
Update Notice – Version 8 (Display Correction)

After the previous update, some users experienced issues with the display of the update description in the preview/image section on TradingView. This affected only the visual presentation of the update notes and did not impact the script itself.

The underlying code of the indicator has not been changed in any way.
All functions, calculations, and settings continue to work exactly as before.

This small “update of the update” fixes the display issue so the description is shown correctly.
The indicator logic remains completely unchanged.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.