Fair Value Gap Oscillator | Flux Charts💎 GENERAL OVERVIEW
Introducing the new Fair Value Gap Oscillator (FVG Oscillator) indicator! This unique indicator identifies and tracks Fair Value Gaps (FVGs) in price action, presenting them in an oscillator format to reveal market momentum based on FVG strength. It highlights bullish and bearish FVGs while enabling traders to adjust detection sensitivity and apply volume and ATR-based filters for more precise setups. For more information about the process, check the "📌 HOW DOES IT WORK" section.
Features of the new FVG Oscillator:
Fully Customizable FVG Detection
An Oscillator Approach To FVGs
Divergence Markers For Potential Reversals
Alerts For Divergence Labels
Customizable Styling
📌 HOW DOES IT WORK?
Fair Value Gaps are price gaps within bars that indicate inefficiencies, often filled as the market retraces. The FVG Oscillator scans historical bars to identify these gaps, then filters them based on ATR or volume. Each FVG is marked as bullish or bearish according to the trend direction that preceded its formation.
An oscillator is calculated using recent FVGs with this formula :
1. The Oscillator starts as 0.
2. When a new FVG Appears, it contributes (FVG Width / ATR) to the oscillator of the corresponding type.
3. Each confirmed bar, the oscillator is recalculated as OSC = OSC * (1 - Decay Coefficient)
The oscillator aggregates and decays past FVGs, allowing recent FVG activity to dominate the signal. This approach emphasizes current market momentum, with oscillations moving bullish or bearish based on FVG intensity. Divergences are marked where FVG oscillations suggest potential reversals. Bullish Divergence conditions are as follows :
1. The current candlestick low must be the lowest of last 25 bars.
2. Net Oscillator (Shown in gray line by default) must be > 0.
3. The current Bullish FVG Oscillator value should be no more than 0.1 below the highest value from the last 25 bars.
Traders can use divergence signals to get an idea of potential reversals, and use the Net FVG Oscillator as a trend following marker.
🚩 UNIQUENESS
The Fair Value Gap Oscillator stands out by converting FVG activity into an oscillator format, providing a momentum-based visualization of FVGs that reveals market sentiment dynamically. Unlike traditional indicators that statically mark FVG zones, the oscillator decays older FVGs over time, showing only the most recent, relevant activity. This approach allows for real-time insight into market conditions and potential reversals based on oscillating FVG strength, making it both intuitive and powerful for momentum trading.
Another unique feature is the combination of customizable ATR and volume filters, letting traders adapt the indicator to match their strategy and market type. You can also set-up alerts for bullish & bearish divergences.
⚙️ SETTINGS
1. General Configuration
Decay Coefficient -> The decay coefficient for oscillators. Increasing this setting will result in oscillators giving the weight to recent FVGs, while decreasing it will distribute the weight equally to the past and recent FVGs.
2. Fair Value Gaps
Zone Invalidation -> Select between Wick & Close price for FVG Zone Invalidation.
Zone Filtering -> With "Average Range" selected, algorithm will find FVG zones in comparison with average range of last bars in the chart. With the "Volume Threshold" option, you may select a Volume Threshold % to spot FVGs with a larger total volume than average.
FVG Detection -> With the "Same Type" option, all 3 bars that formed the FVG should be the same type. (Bullish / Bearish). If the "All" option is selected, bar types may vary between Bullish / Bearish.
Detection Sensitivity -> You may select between Low, Normal or High FVG detection sensitivity. This will essentially determine the size of the spotted FVGs, with lower sensitivies resulting in spotting bigger FVGs, and higher sensitivies resulting in spotting all sizes of FVGs.
3. Style
Divergence Labels On -> You can switch divergence labels to show up on the chart or the oscillator plot.
Fairvaluegaposcillator
FVG Detector LibraryLibrary "FVG Detector Library"
🔵 Introduction
To save time and improve accuracy in your scripts for identifying Fair Value Gaps (FVGs), you can utilize this library. Apart from detecting and plotting FVGs, one of the most significant advantages of this script is the ability to filter FVGs, which you'll learn more about below. Additionally, the plotting of each FVG continues until either a new FVG occurs or the current FVG is mitigated.
🔵 Definition
Fair Value Gap (FVG) refers to a situation where three consecutive candlesticks do not overlap. Based on this definition, the minimum conditions for detecting a fair gap in the ascending scenario are that the minimum price of the last candlestick should be greater than the maximum price of the third candlestick, and in the descending scenario, the maximum price of the last candlestick should be smaller than the minimum price of the third candlestick.
If the filter is turned off, all FVGs that meet at least the minimum conditions are identified. This mode is simplistic and results in a high number of identified FVGs.
If the filter is turned on, you have four options to filter FVGs :
1. Very Aggressive : In addition to the initial condition, another condition is added. For ascending FVGs, the maximum price of the last candlestick should be greater than the maximum price of the middle candlestick. Similarly, for descending FVGs, the minimum price of the last candlestick should be smaller than the minimum price of the middle candlestick. In this mode, a very small number of FVGs are eliminated.
2. Aggressive : In addition to the conditions of the Very Aggressive mode, in this mode, the size of the middle candlestick should not be small. This mode eliminates more FVGs compared to the Very Aggressive mode.
3. Defensive : In addition to the conditions of the Very Aggressive mode, in this mode, the size of the middle candlestick should be relatively large, and most of it should consist of the body. Also, for identifying ascending FVGs, the second and third candlesticks must be positive, and for identifying descending FVGs, the second and third candlesticks must be negative. In this mode, a significant number of FVGs are eliminated, and the remaining FVGs have a decent quality.
4. Very Defensive : In addition to the conditions of the Defensive mode, the first and third candlesticks should not resemble very small-bodied doji candlesticks. In this mode, the majority of FVGs are filtered out, and the remaining ones are of higher quality.
By default, we recommend using the Defensive mode.
🔵 How to Use
🟣 Parameters
To utilize this library, you need to provide four input parameters to the function.
"FVGFilter" determines whether you wish to apply a filter on FVGs or not. The possible inputs for this parameter are "On" and "Off", provided as strings.
"FVGFilterType" determines the type of filter to be applied to the found FVGs. These filters include four modes: "Very Defensive", "Defensive", "Aggressive", and "Very Aggressive", respectively exhibiting decreasing sensitivity and indicating a higher number of Fair Value Gaps (FVG).
The parameter "ShowDeFVG" is a Boolean value defined as either "true" or "false". If this value is "true", FVGs are shown during the Bullish Trend; however, if it is "false", they are not displayed.
The parameter "ShowSuFVG" is a Boolean value defined as either "true" or "false". If this value is "true", FVGs are displayed during the Bearish Trend; however, if it is "false", they are not displayed.
FVGDetector(FVGFilter, FVGFilterType, ShowDeFVG, ShowSuFVG)
Parameters:
FVGFilter (string)
FVGFilterType (string)
ShowDeFVG (bool)
ShowSuFVG (bool)
🟣 Import Library
You can use the "FVG Detector" library in your script using the following expression:
import TFlab/FVGDetectorLibrary/1 as FVG
🟣 Input Parameters
The descriptions related to the input parameters were provided in the "Parameter" section. In this section, for your convenience, the code related to the inputs is also included, and you can copy and paste it into your script.
PFVGFilter = input.string('On', 'FVG Filter', )
PFVGFilterType = input.string('Defensive', 'FVG Filter Type', )
PShowDeFVG = input.bool(true, ' Show Demand FVG')
PShowSuFVG = input.bool(true, ' Show Supply FVG')
🟣 Call Function
You can copy the following code into your script to call the FVG function. This code is based on the naming conventions provided in the "Input Parameter" section, so if you want to use exactly this code, you should have similar parameter names or have copied the "Input Parameter" values.
FVG.FVGDetector(PFVGFilter, PFVGFilterType, PShowDeFVG, PShowSuFVG)