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)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.