Detects 3-candle price imbalances and ICT Fair Value Gaps (FVG) with real-time fill tracking and mitigation status.
Copy and paste this code directly into your TradingView Pine Editor
//@version=5
indicator("FxSnip - Fair Value Gap (FVG) Detector", "FxSnip FVG Detector", overlay=true, max_boxes_count=500)
// Inputs
minGapTicks = input.int(5, "Min Gap Size (Ticks)", minval=1)
showCE = input.bool(true, "Show 50% Consequent Encroachment (CE)")
bullColor = input.color(color.new(color.emerald, 75), "Bullish FVG Box Color")
bearColor = input.color(color.new(color.rose, 75), "Bearish FVG Box Color")
// Bullish FVG: Low of candle 1 > High of candle 3
isBullFVG = low[0] > high[2] and (low[0] - high[2]) >= (minGapTicks * syminfo.mintick)
// Bearish FVG: High of candle 1 < Low of candle 3
isBearFVG = high[0] < low[2] and (low[2] - high[0]) >= (minGapTicks * syminfo.mintick)
if isBullFVG
b = box.new(left=bar_index-2, top=low[0], right=bar_index+20, bottom=high[2], bgcolor=bullColor, border_color=color.emerald)
if showCE
mid = (low[0] + high[2]) / 2
line.new(bar_index-2, mid, bar_index+20, mid, color=color.emerald, style=line.style_dotted)
if isBearFVG
b = box.new(left=bar_index-2, top=low[2], right=bar_index+20, bottom=high[0], bgcolor=bearColor, border_color=color.rose)
if showCE
mid = (low[2] + high[0]) / 2
line.new(bar_index-2, mid, bar_index+20, mid, color=color.rose, style=line.style_dotted)
.ex5 / .mq5 file.The Fair Value Gap (FVG) Auto-Detector identifies high-probability liquidity imbalances formed when price moves aggressively in one direction, leaving an unfilled price void between Candle 1 and Candle 3.
Need this indicator converted into an automated MT5 Expert Advisor or customized for your specific trading rules?
Order Custom Coding →Loading activity...
Just now