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)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.