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