OPEN-SOURCE SCRIPT

SMC Analysis - Fair Value Gaps (Enhanced)

225
SMC Analysis - Fair Value Gaps (Enhanced) Script Summary
Overview
The "SMC Analysis - Fair Value Gaps (Enhanced)" script, written in Pine Script (version 6), is a technical analysis indicator designed for TradingView to identify and visualize Fair Value Gaps (FVGs) on a price chart. It supports both the main timeframe and multiple higher timeframes (MTF) for comprehensive market analysis. FVGs are price gaps formed by a three-candle pattern, indicating potential areas of market inefficiency where price may return to fill the gap.

Key Features

FVG Detection:

Identifies bullish FVGs: Occur when the high of a candle two bars prior is lower than the low of the current candle, with the middle candle being bullish (close > open).
Identifies bearish FVGs: Occur when the low of a candle two bars prior is higher than the high of the current candle, with the middle candle being bearish (close < open).
Visualizes FVGs as colored boxes on the chart (green for bullish, red for bearish).


Mitigation Tracking:

Tracks when FVGs are touched (price overlaps the gap range) or mitigated (price fully closes the gap).
Strict Mode: Marks an FVG as mitigated when price touches the gap range.
Normal Mode: Requires a full breakthrough (price crossing the gap’s bottom for bullish FVGs or top for bearish FVGs) for mitigation.
Optionally converts FVG box borders to dashed lines and increases transparency when partially touched.


Multi-Timeframe (MTF) Support:

Analyzes FVGs on three user-defined higher timeframes (default: 15m, 60m, 240m).
Displays MTF FVGs with distinct labels and slightly more transparent colors.
Ensures no duplicate processing of MTF bars to maintain performance.


Customization Options:

FVG Length: Adjustable duration for how long FVGs are displayed (default: 20 bars).
Show/Hide FVGs: Toggle visibility for main timeframe and each MTF.
Color Customization: User-defined colors for bullish and bearish FVGs (default: green and red).
Display Options: Toggle for showing dashed lines after partial touches and strict mitigation mode.


Performance Optimization:

Limits the number of displayed boxes (50 for main timeframe, 20 per MTF) to prevent performance issues.
Automatically removes older boxes to maintain a clean chart.


Functionality

Visualization: Draws boxes around detected FVGs, with customizable colors and text labels ("FVG" for main timeframe, "FVG [timeframe]" for MTF).
Dynamic Updates: Extends or terminates FVG boxes based on mitigation status and user settings.
Efficient Storage: Uses arrays to manage FVG data (boxes, tops, bottoms, indices, mitigation status, and touch status) separately for main and MTF analyses.

Use Case
This indicator is designed for traders using Smart Money Concepts (SMC) to identify areas of market inefficiency (FVGs) for potential price reversals or continuations. The MTF support allows analysis across different timeframes, aiding in confirming trends or spotting higher-timeframe support/resistance zones.

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.