OPEN-SOURCE SCRIPT
FVG ATR

FVG ATR — Fair Value Gap Size Measured in ATR Units
This Pine Script v6 indicator detects Fair Value Gaps and displays their size as a ratio of the Average True Range, providing traders with a normalized measurement of gap significance across different market conditions and timeframes.
Key Features
Automatic FVG Detection
The indicator identifies bullish and bearish Fair Value Gaps using the standard three-candle pattern. Bullish FVGs occur when the current low exceeds the high from two bars ago, while bearish FVGs occur when the current high falls below the low from two bars ago.
ATR Ratio Calculation
Each detected FVG is measured against the current Average True Range at the moment of detection. The ratio is displayed as a compact label next to the gap, showing values like "ATR: 0.75" or "ATR: 1.41". This normalization allows comparison of gap significance across volatile and calm market periods.
Minimal Visual Footprint
Labels are displayed directly on the chart without boxes or lines, using customizable text sizes from tiny to large. The default tiny size ensures the chart remains uncluttered while providing essential information at a glance.
Highly Customizable Display
All visual aspects are configurable through input parameters, including label position (top, middle, or bottom of gap), text size, text color, optional background, and horizontal offset from the detection candle.
Customizable Parameters
Detection Settings
Detect Bullish FVG: Enable or disable detection of bullish gaps. Default is enabled.
Detect Bearish FVG: Enable or disable detection of bearish gaps. Default is enabled.
Min Size (pips): Filter out small gaps below the specified threshold. One pip equals 10 ticks for most Forex pairs. Default is 10 pips.
ATR Calculation
ATR Period: Period length for Average True Range calculation. Default is 14, adjustable to match your trading strategy.
Label Settings
Label Position: Vertical placement of the text label relative to the FVG zone. Options are Top, Middle, or Bottom. Default is Middle.
Label Size: Text size from Tiny (smallest), Small, Normal, to Large. Default is Tiny for minimal chart clutter.
Text Color: Custom color for label text. Default is white for visibility on dark themes.
Show Background: Toggle to display labels with a colored background box or as transparent text only. Default is disabled for cleaner appearance.
Background Color: Custom color for label background when enabled. Default is semi-transparent gray.
Label Offset (bars): Horizontal distance in bars between the detection candle and the label. Set to 0 for labels directly on the candle, or increase for separation. Default is 0.
Recommended Use Cases
Multi-Timeframe Analysis
Compare FVG significance across different timeframes by observing ATR ratios. A 1.5 ATR gap on the 1-hour chart may indicate different significance than the same ratio on the daily chart.
Volatility-Adjusted Trading
Use ATR ratios to filter for only the most significant gaps. For example, only trade FVGs with ratios above 1.0 to focus on gaps larger than typical price movement.
Risk Management
Size positions based on gap magnitude relative to current volatility. Larger ATR ratios may warrant tighter stops or smaller position sizes.
Market Efficiency Analysis
Track how quickly and completely different-sized gaps get filled. Gaps with higher ATR ratios may take longer to fill or act as stronger support and resistance zones.
Technical Details
This indicator is written in Pine Script v6 and follows all recommended coding standards including strict 4-space indentation, lazy boolean evaluation, and proper type declarations. The script uses array-based storage to maintain up to 500 labels simultaneously.
The ATR ratio is calculated at the moment of FVG detection and remains fixed, never repainting. The calculation divides the FVG height (distance between gap boundaries) by the current ATR value using the specified period. Division by zero is protected with conditional logic.
Label positioning uses the xloc.bar_index and yloc.price system for precise placement. The horizontal offset parameter allows traders to adjust label spacing based on chart zoom level and personal preference. Text formatting uses str.tostring with two decimal places for clear ratio display.
Important Notes
The indicator never repaints as all FVG detections and ATR calculations are fixed upon bar confirmation. Labels persist on the chart until the maximum label count is reached, at which point the oldest labels are automatically removed by TradingView.
For optimal performance on charts with many FVGs, consider increasing the minimum pip size filter or using smaller label sizes. The tiny size option provides the smallest possible text for maximum chart clarity.
Installation and Usage
Copy the source code into the TradingView Pine Editor and add the indicator to your chart. The overlay parameter is set to true, allowing labels to display directly on price candles. Configure all parameters through the indicator settings panel to match your trading style and visual preferences.
100% Pine Script v6 indicator — No repaint — Open source
This Pine Script v6 indicator detects Fair Value Gaps and displays their size as a ratio of the Average True Range, providing traders with a normalized measurement of gap significance across different market conditions and timeframes.
Key Features
Automatic FVG Detection
The indicator identifies bullish and bearish Fair Value Gaps using the standard three-candle pattern. Bullish FVGs occur when the current low exceeds the high from two bars ago, while bearish FVGs occur when the current high falls below the low from two bars ago.
ATR Ratio Calculation
Each detected FVG is measured against the current Average True Range at the moment of detection. The ratio is displayed as a compact label next to the gap, showing values like "ATR: 0.75" or "ATR: 1.41". This normalization allows comparison of gap significance across volatile and calm market periods.
Minimal Visual Footprint
Labels are displayed directly on the chart without boxes or lines, using customizable text sizes from tiny to large. The default tiny size ensures the chart remains uncluttered while providing essential information at a glance.
Highly Customizable Display
All visual aspects are configurable through input parameters, including label position (top, middle, or bottom of gap), text size, text color, optional background, and horizontal offset from the detection candle.
Customizable Parameters
Detection Settings
Detect Bullish FVG: Enable or disable detection of bullish gaps. Default is enabled.
Detect Bearish FVG: Enable or disable detection of bearish gaps. Default is enabled.
Min Size (pips): Filter out small gaps below the specified threshold. One pip equals 10 ticks for most Forex pairs. Default is 10 pips.
ATR Calculation
ATR Period: Period length for Average True Range calculation. Default is 14, adjustable to match your trading strategy.
Label Settings
Label Position: Vertical placement of the text label relative to the FVG zone. Options are Top, Middle, or Bottom. Default is Middle.
Label Size: Text size from Tiny (smallest), Small, Normal, to Large. Default is Tiny for minimal chart clutter.
Text Color: Custom color for label text. Default is white for visibility on dark themes.
Show Background: Toggle to display labels with a colored background box or as transparent text only. Default is disabled for cleaner appearance.
Background Color: Custom color for label background when enabled. Default is semi-transparent gray.
Label Offset (bars): Horizontal distance in bars between the detection candle and the label. Set to 0 for labels directly on the candle, or increase for separation. Default is 0.
Recommended Use Cases
Multi-Timeframe Analysis
Compare FVG significance across different timeframes by observing ATR ratios. A 1.5 ATR gap on the 1-hour chart may indicate different significance than the same ratio on the daily chart.
Volatility-Adjusted Trading
Use ATR ratios to filter for only the most significant gaps. For example, only trade FVGs with ratios above 1.0 to focus on gaps larger than typical price movement.
Risk Management
Size positions based on gap magnitude relative to current volatility. Larger ATR ratios may warrant tighter stops or smaller position sizes.
Market Efficiency Analysis
Track how quickly and completely different-sized gaps get filled. Gaps with higher ATR ratios may take longer to fill or act as stronger support and resistance zones.
Technical Details
This indicator is written in Pine Script v6 and follows all recommended coding standards including strict 4-space indentation, lazy boolean evaluation, and proper type declarations. The script uses array-based storage to maintain up to 500 labels simultaneously.
The ATR ratio is calculated at the moment of FVG detection and remains fixed, never repainting. The calculation divides the FVG height (distance between gap boundaries) by the current ATR value using the specified period. Division by zero is protected with conditional logic.
Label positioning uses the xloc.bar_index and yloc.price system for precise placement. The horizontal offset parameter allows traders to adjust label spacing based on chart zoom level and personal preference. Text formatting uses str.tostring with two decimal places for clear ratio display.
Important Notes
The indicator never repaints as all FVG detections and ATR calculations are fixed upon bar confirmation. Labels persist on the chart until the maximum label count is reached, at which point the oldest labels are automatically removed by TradingView.
For optimal performance on charts with many FVGs, consider increasing the minimum pip size filter or using smaller label sizes. The tiny size option provides the smallest possible text for maximum chart clarity.
Installation and Usage
Copy the source code into the TradingView Pine Editor and add the indicator to your chart. The overlay parameter is set to true, allowing labels to display directly on price candles. Configure all parameters through the indicator settings panel to match your trading style and visual preferences.
100% Pine Script v6 indicator — No repaint — Open source
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.