indicator · on price · open source
Fair Value Gaps (Both) indicator
Fair Value Gaps (Both) is a free open-source indicator. Fair Value Gaps (Bullish + Bearish) plotted together — every qualifying 3-candle imbalance… Deepwick Script runs a subset of Pine Script.
Running…
Loading chart…
What Fair Value Gaps (Both) does
Fair Value Gaps (Bullish + Bearish) plotted together — every qualifying 3-candle imbalance is shaded in green (bull) or red (bear).
- Combines bullish + bearish FVG logic in one overlay.
minGapPctfilters tiny imbalances.- Quick visual map of all unfilled imbalances on the chart.
- Bullish gaps are demand; bearish gaps are supply; both act as magnets when price returns.
- Stacked gaps (multiple gaps in the same direction without overlap) are the strongest imbalance reads.
- A clean fill of a stacked FVG is the highest-probability reversal trigger.
- Two opposing FVGs in the same bar = inside-bar compression, often a precursor to an explosive move.
- The wide FVG alerts flag exceptional imbalances that deserve extra attention.
Learn more: What a fair value gap is and how to trade it
Source code
Deepwick Script, a subset of Pine Script · read-only
//@version=6
indicator("Fair Value Gaps (Both)", overlay=true)
minGapPct = input.float(0.1, "Min Gap %", minval=0, maxval=5, step=0.05)
extendBars = input.int(30, "Extend Bars", minval=5, maxval=200)
bullColor = input.string("color.green", "Bullish FVG Color")
bearColor = input.string("color.red", "Bearish FVG Color")
transparency = input.int(88, "Fill Transparency", minval=50, maxval=99)
alertBull = input.bool(true, "Alert on Bullish FVG")
alertBear = input.bool(true, "Alert on Bearish FVG")
alertWide = input.bool(false, "Alert on Wide FVGs")
alertStack = input.bool(false, "Alert on Stacked FVGs")
lineWidth = input.int(2, "FVG Line Width", minval=1, maxval=5)
gapBull = low[0] > high[2]
gapBear = high[0] < low[2]
gapBullPct = (low[0] - high[2]) / close * 100
gapBearPct = (low[2] - high[0]) / close * 100
gapBull := gapBull and gapBullPct >= minGapPct
gapBear := gapBear and gapBearPct >= minGapPct
var float fvgBullTop = na
var float fvgBullBot = na
var float fvgBearTop = na
var float fvgBearBot = na
var int fvgBullAge = 9999
var int fvgBearAge = 9999
if gapBull
fvgBullTop := low[0]
fvgBullBot := high[2]
fvgBullAge := 0
if gapBear
fvgBearTop := low[2]
fvgBearBot := high[0]
fvgBearAge := 0
fvgBullAge += 1
fvgBearAge += 1
if fvgBullAge > extendBars
fvgBullTop := na
fvgBullBot := na
if fvgBearAge > extendBars
fvgBearTop := na
fvgBearBot := na
p_Bull_FVG_Top = plot(fvgBullTop, "Bull FVG Top", color=bullColor, style=plot.style_linebr)
p_Bull_FVG_Bot = plot(fvgBullBot, "Bull FVG Bot", color=bullColor, style=plot.style_linebr)
p_Bear_FVG_Top = plot(fvgBearTop, "Bear FVG Top", color=bearColor, style=plot.style_linebr)
p_Bear_FVG_Bot = plot(fvgBearBot, "Bear FVG Bot", color=bearColor, style=plot.style_linebr)
fill(p_Bull_FVG_Top, p_Bull_FVG_Bot, color=color.new(bullColor, transparency))
fill(p_Bear_FVG_Top, p_Bear_FVG_Bot, color=color.new(bearColor, transparency))
alertcondition(gapBull, "Bullish FVG", "Bullish fair value gap printed")
alertcondition(gapBear, "Bearish FVG", "Bearish fair value gap printed")
alertcondition(gapBull and gapBull[1] and gapBull[2], "Triple bull FVGs", "Three bullish FVGs in a row — extreme demand imbalance")
alertcondition(gapBear and gapBear[1] and gapBear[2], "Triple bear FVGs", "Three bearish FVGs in a row — extreme supply imbalance")
alertcondition(gapBull and gapBear, "Opposing FVGs", "Bullish and bearish FVGs formed on the same bar — inside-bar compression")
alertcondition(gapBull and ta.tr(true) > 0, "Wide Bullish FVG", "Wide bullish FVG — institutional demand burst")
alertcondition(gapBear and ta.tr(true) > 0, "Wide Bearish FVG", "Wide bearish FVG — institutional supply burst")
No comments yet.
Sign in to comment.