OPEN-SOURCE SCRIPT
Liquidity Sweep + FVG Entry Model

//version=5
indicator("Liquidity Sweep + FVG Entry Model", overlay = true, max_labels_count = 500, max_lines_count = 500)
// Just to confirm indicator is loaded, always plot close:
plot(close, color = color.new(color.white, 0))
// ─────────────────────────────────────────────
// PARAMETERS
// ─────────────────────────────────────────────
len = input.int(5, "Liquidity Lookback")
tpMultiplier = input.float(2.0, "TP Distance Multiplier")
// ─────────────────────────────────────────────
// LIQUIDITY SWEEP DETECTION
// ─────────────────────────────────────────────
lowestPrev = ta.lowest(low, len)
highestPrev = ta.highest(high, len)
sweepLow = low < lowestPrev and close > lowestPrev
sweepHigh = high > highestPrev and close < highestPrev
// Plot liquidity levels
plot(lowestPrev, "Liquidity Low", color = color.new(color.blue, 40), style = plot.style_line)
plot(highestPrev, "Liquidity High", color = color.new(color.red, 40), style = plot.style_line)
// ─────────────────────────────────────────────
// DISPLACEMENT DETECTION
// ─────────────────────────────────────────────
bullDisp = sweepLow and close > open and close > close[1]
bearDisp = sweepHigh and close < open and close < close[1]
// ─────────────────────────────────────────────
// FAIR VALUE GAP (FVG)
// ─────────────────────────────────────────────
bullFVG = low > high[2]
bearFVG = high < low[2]
// we’ll store the last FVG lines
var line fvgTop = na
var line fvgBottom = na
// clear old FVG lines when new one appears
if bullFVG or bearFVG
if not na(fvgTop)
line.delete(fvgTop)
if not na(fvgBottom)
line.delete(fvgBottom)
// Bullish FVG box
if bullFVG
fvgTop := line.new(bar_index[2], high[2], bar_index, high[2], extend = extend.right, color = color.new(color.green, 60))
fvgBottom := line.new(bar_index[2], low, bar_index, low, extend = extend.right, color = color.new(color.green, 60))
// Bearish FVG box
if bearFVG
fvgTop := line.new(bar_index[2], low[2], bar_index, low[2], extend = extend.right, color = color.new(color.red, 60))
fvgBottom := line.new(bar_index[2], high, bar_index, high, extend = extend.right, color = color.new(color.red, 60))
// ─────────────────────────────────────────────
// ENTRY, SL, TP CONDITIONS
// ─────────────────────────────────────────────
var line slLine = na
var line tp1Line = na
var line tp2Line = na
f_deleteLineIfExists(line_id) =>
if not na(line_id)
line.delete(line_id)
if bullDisp and bullFVG
sl = low
tp1 = close + (close - sl) * tpMultiplier
tp2 = close + (close - sl) * (tpMultiplier * 1.5)
f_deleteLineIfExists(slLine)
f_deleteLineIfExists(tp1Line)
f_deleteLineIfExists(tp2Line)
slLine := line.new(bar_index, sl, bar_index + 1, sl, extend = extend.right, color = color.red)
tp1Line := line.new(bar_index, tp1, bar_index + 1, tp1, extend = extend.right, color = color.green)
tp2Line := line.new(bar_index, tp2, bar_index + 1, tp2, extend = extend.right, color = color.green)
label.new(bar_index, close, "BUY Entry\nFVG Retest\nSL Below Sweep",
style = label.style_label_up, color = color.new(color.green, 0), textcolor = color.white)
if bearDisp and bearFVG
sl = high
tp1 = close - (sl - close) * tpMultiplier
tp2 = close - (sl - close) * (tpMultiplier * 1.5)
f_deleteLineIfExists(slLine)
f_deleteLineIfExists(tp1Line)
f_deleteLineIfExists(tp2Line)
slLine := line.new(bar_index, sl, bar_index + 1, sl, extend = extend.right, color = color.red)
tp1Line := line.new(bar_index, tp1, bar_index + 1, tp1, extend = extend.right, color = color.green)
tp2Line := line.new(bar_index, tp2, bar_index + 1, tp2, extend = extend.right, color = color.green)
label.new(bar_index, close, "SELL Entry\nFVG Retest\nSL Above Sweep",
style = label.style_label_down, color = color.new(color.red, 0), textcolor = color.white)
indicator("Liquidity Sweep + FVG Entry Model", overlay = true, max_labels_count = 500, max_lines_count = 500)
// Just to confirm indicator is loaded, always plot close:
plot(close, color = color.new(color.white, 0))
// ─────────────────────────────────────────────
// PARAMETERS
// ─────────────────────────────────────────────
len = input.int(5, "Liquidity Lookback")
tpMultiplier = input.float(2.0, "TP Distance Multiplier")
// ─────────────────────────────────────────────
// LIQUIDITY SWEEP DETECTION
// ─────────────────────────────────────────────
lowestPrev = ta.lowest(low, len)
highestPrev = ta.highest(high, len)
sweepLow = low < lowestPrev and close > lowestPrev
sweepHigh = high > highestPrev and close < highestPrev
// Plot liquidity levels
plot(lowestPrev, "Liquidity Low", color = color.new(color.blue, 40), style = plot.style_line)
plot(highestPrev, "Liquidity High", color = color.new(color.red, 40), style = plot.style_line)
// ─────────────────────────────────────────────
// DISPLACEMENT DETECTION
// ─────────────────────────────────────────────
bullDisp = sweepLow and close > open and close > close[1]
bearDisp = sweepHigh and close < open and close < close[1]
// ─────────────────────────────────────────────
// FAIR VALUE GAP (FVG)
// ─────────────────────────────────────────────
bullFVG = low > high[2]
bearFVG = high < low[2]
// we’ll store the last FVG lines
var line fvgTop = na
var line fvgBottom = na
// clear old FVG lines when new one appears
if bullFVG or bearFVG
if not na(fvgTop)
line.delete(fvgTop)
if not na(fvgBottom)
line.delete(fvgBottom)
// Bullish FVG box
if bullFVG
fvgTop := line.new(bar_index[2], high[2], bar_index, high[2], extend = extend.right, color = color.new(color.green, 60))
fvgBottom := line.new(bar_index[2], low, bar_index, low, extend = extend.right, color = color.new(color.green, 60))
// Bearish FVG box
if bearFVG
fvgTop := line.new(bar_index[2], low[2], bar_index, low[2], extend = extend.right, color = color.new(color.red, 60))
fvgBottom := line.new(bar_index[2], high, bar_index, high, extend = extend.right, color = color.new(color.red, 60))
// ─────────────────────────────────────────────
// ENTRY, SL, TP CONDITIONS
// ─────────────────────────────────────────────
var line slLine = na
var line tp1Line = na
var line tp2Line = na
f_deleteLineIfExists(line_id) =>
if not na(line_id)
line.delete(line_id)
if bullDisp and bullFVG
sl = low
tp1 = close + (close - sl) * tpMultiplier
tp2 = close + (close - sl) * (tpMultiplier * 1.5)
f_deleteLineIfExists(slLine)
f_deleteLineIfExists(tp1Line)
f_deleteLineIfExists(tp2Line)
slLine := line.new(bar_index, sl, bar_index + 1, sl, extend = extend.right, color = color.red)
tp1Line := line.new(bar_index, tp1, bar_index + 1, tp1, extend = extend.right, color = color.green)
tp2Line := line.new(bar_index, tp2, bar_index + 1, tp2, extend = extend.right, color = color.green)
label.new(bar_index, close, "BUY Entry\nFVG Retest\nSL Below Sweep",
style = label.style_label_up, color = color.new(color.green, 0), textcolor = color.white)
if bearDisp and bearFVG
sl = high
tp1 = close - (sl - close) * tpMultiplier
tp2 = close - (sl - close) * (tpMultiplier * 1.5)
f_deleteLineIfExists(slLine)
f_deleteLineIfExists(tp1Line)
f_deleteLineIfExists(tp2Line)
slLine := line.new(bar_index, sl, bar_index + 1, sl, extend = extend.right, color = color.red)
tp1Line := line.new(bar_index, tp1, bar_index + 1, tp1, extend = extend.right, color = color.green)
tp2Line := line.new(bar_index, tp2, bar_index + 1, tp2, extend = extend.right, color = color.green)
label.new(bar_index, close, "SELL Entry\nFVG Retest\nSL Above Sweep",
style = label.style_label_down, color = color.new(color.red, 0), textcolor = color.white)
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.