OPEN-SOURCE SCRIPT

Fair Value Gap Finder

128
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. קרא עוד בתנאים וההגבלות.