OPEN-SOURCE SCRIPT
Fair Value Gap (FVG) Detector

//version=5
indicator("Fair Value Gap (FVG) Detector", overlay=true, max_boxes_count=500)
// === USER INPUTS ===
showBullish = input.bool(true, "Show Bullish FVG")
showBearish = input.bool(true, "Show Bearish FVG")
removeFilled = input.bool(true, "Remove Filled Gaps")
extendBars = input.int(20, "Extend Boxes (Bars)", minval=1)
// === STORAGE ARRAYS ===
var box[] bullishBoxes = array.new_box()
var box[] bearishBoxes = array.new_box()
// === BULLISH FVG CONDITION ===
// Candle structure: low of current > high of 2 candles ago
bullishFVG = low > high[2]
// === BEARISH FVG CONDITION ===
// Candle structure: high of current < low of 2 candles ago
bearishFVG = high < low[2]
// === DRAW BULLISH FVG ===
if showBullish and bullishFVG
top = low
bottom = high[2]
newBox = box.new(left=bar_index[2], right=bar_index + extendBars,
top=top, bottom=bottom,
border_color=color.green,
bgcolor=color.new(color.green, 85))
array.push(bullishBoxes, newBox)
// === DRAW BEARISH FVG ===
if showBearish and bearishFVG
top = low[2]
bottom = high
newBox = box.new(left=bar_index[2], right=bar_index + extendBars,
top=top, bottom=bottom,
border_color=color.red,
bgcolor=color.new(color.red, 85))
array.push(bearishBoxes, newBox)
// === REMOVE FILLED GAPS ===
if removeFilled
// Check Bullish
for i = array.size(bullishBoxes) - 1 to 0
b = array.get(bullishBoxes, i)
if close <= box.get_bottom(b)
box.delete(b)
array.remove(bullishBoxes, i)
// Check Bearish
for i = array.size(bearishBoxes) - 1 to 0
b = array.get(bearishBoxes, i)
if close >= box.get_top(b)
box.delete(b)
array.remove(bearishBoxes, i)
indicator("Fair Value Gap (FVG) Detector", overlay=true, max_boxes_count=500)
// === USER INPUTS ===
showBullish = input.bool(true, "Show Bullish FVG")
showBearish = input.bool(true, "Show Bearish FVG")
removeFilled = input.bool(true, "Remove Filled Gaps")
extendBars = input.int(20, "Extend Boxes (Bars)", minval=1)
// === STORAGE ARRAYS ===
var box[] bullishBoxes = array.new_box()
var box[] bearishBoxes = array.new_box()
// === BULLISH FVG CONDITION ===
// Candle structure: low of current > high of 2 candles ago
bullishFVG = low > high[2]
// === BEARISH FVG CONDITION ===
// Candle structure: high of current < low of 2 candles ago
bearishFVG = high < low[2]
// === DRAW BULLISH FVG ===
if showBullish and bullishFVG
top = low
bottom = high[2]
newBox = box.new(left=bar_index[2], right=bar_index + extendBars,
top=top, bottom=bottom,
border_color=color.green,
bgcolor=color.new(color.green, 85))
array.push(bullishBoxes, newBox)
// === DRAW BEARISH FVG ===
if showBearish and bearishFVG
top = low[2]
bottom = high
newBox = box.new(left=bar_index[2], right=bar_index + extendBars,
top=top, bottom=bottom,
border_color=color.red,
bgcolor=color.new(color.red, 85))
array.push(bearishBoxes, newBox)
// === REMOVE FILLED GAPS ===
if removeFilled
// Check Bullish
for i = array.size(bullishBoxes) - 1 to 0
b = array.get(bullishBoxes, i)
if close <= box.get_bottom(b)
box.delete(b)
array.remove(bullishBoxes, i)
// Check Bearish
for i = array.size(bearishBoxes) - 1 to 0
b = array.get(bearishBoxes, i)
if close >= box.get_top(b)
box.delete(b)
array.remove(bearishBoxes, i)
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.