OPEN-SOURCE SCRIPT

Fair Value Gap Finder

127
Functionality

Detection of Fair Value Gaps:

A bullish Fair Value Gap (FVG Up) is identified when the low of two candles before the current bar (low[2]) is greater than the high of the current bar (high[0]).

A bearish Fair Value Gap (FVG Down) is identified when the high of two candles before the current bar (high[2]) is lower than the low of the current bar (low[0]).
Color Coding:

Bullish Fair Value Gaps are highlighted in green to indicate potential areas of support.
Bearish Fair Value Gaps are highlighted in red to indicate potential areas of resistance.
Visualization Using Rectangles:

If an FVG is detected, the script creates a rectangle spanning a fixed number of bars (right=bar_index+5) to visualize the price inefficiency.

The rectangle extends from the upper to the lower boundary of the gap and has a semi-transparent fill (bgcolor=color.new(color, 90)) for better readability.

Implementation Details

Variable Initialization: The script defines floating-point variables (fvgUpTop, fvgUpBottom, fvgDownTop, fvgDownBottom) to store the price levels of identified gaps.

Conditional Assignments: When an FVG is detected, the corresponding top and bottom boundaries are assigned to the respective variables.

Box Creation: The box.new function is used to draw a rectangle on the chart, marking the FVG zones for better visualization.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.