本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mr_PrinceTrader
//@version=6
indicator("Institutional Flow Pro [SMC]", overlay=true, max_labels_count=300, max_lines_count=100)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pivotLen = input.int(5, "Swing Pivot Length", minval=2, maxval=50)
showSweeps = input.bool(true, "Show Liquidity Sweeps")
showStructure = input.bool(true, "Show Market Structure")
showLevels = input.bool(true, "Show Liquidity Levels")
showEMA = input.bool(false, "Show Trend EMA")
emaLen = input.int(200, "EMA Length", minval=1)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// COLORS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bullColor = color.rgb(0, 200, 140)
bearColor = color.rgb(240, 70, 90)
levelColor = color.rgb(255, 180, 40)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CONFIRMED SWING POINTS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow = ta.pivotlow(low, pivotLen, pivotLen)
var float lastHigh = na
var float lastLow = na
if not na(pivotHigh)
lastHigh := pivotHigh
if not na(pivotLow)
lastLow := pivotLow
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// LIQUIDITY SWEEP DETECTION
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bullSweep = not na(lastLow) and low < lastLow and close > lastLow and low[1] >= lastLow
bearSweep = not na(lastHigh) and high > lastHigh and close < lastHigh and high[1] <= lastHigh
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MARKET STRUCTURE BREAKS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bullBreak = ta.crossover(close, lastHigh)
bearBreak = ta.crossunder(close, lastLow)
bullBOS = not na(lastHigh) and bullBreak
bearBOS = not na(lastLow) and bearBreak
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// LIQUIDITY LEVELS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot(showLevels ? lastHigh : na, "Buy-Side Liquidity", color=color.new(bearColor, 25), linewidth=1, style=plot.style_stepline)
plot(showLevels ? lastLow : na, "Sell-Side Liquidity", color=color.new(bullColor, 25), linewidth=1, style=plot.style_stepline)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SWEEP SIGNALS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plotshape(showSweeps and bullSweep, title="Bullish Liquidity Sweep", style=shape.labelup, location=location.belowbar, color=bullColor, text="LIQ SWEEP\nBULL", textcolor=color.white, size=size.small)
plotshape(showSweeps and bearSweep, title="Bearish Liquidity Sweep", style=shape.labeldown, location=location.abovebar, color=bearColor, text="LIQ SWEEP\nBEAR", textcolor=color.white, size=size.small)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MARKET STRUCTURE LABELS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plotshape(showStructure and bullBOS, title="Bullish Structure Break", style=shape.triangleup, location=location.belowbar, color=bullColor, text="BOS", textcolor=bullColor, size=size.tiny)
plotshape(showStructure and bearBOS, title="Bearish Structure Break", style=shape.triangledown, location=location.abovebar, color=bearColor, text="BOS", textcolor=bearColor, size=size.tiny)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// OPTIONAL TREND EMA
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
emaValue = ta.ema(close, emaLen)
plot(showEMA ? emaValue : na, "Trend EMA", color=color.orange, linewidth=2)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ALERTS — CONFIRMED CANDLES ONLY
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
alertcondition(bullSweep and barstate.isconfirmed, title="Bullish Liquidity Sweep", message="Institutional Flow Pro: Bullish liquidity sweep on {{ticker}} at {{close}}")
alertcondition(bearSweep and barstate.isconfirmed, title="Bearish Liquidity Sweep", message="Institutional Flow Pro: Bearish liquidity sweep on {{ticker}} at {{close}}")
alertcondition(bullBOS and barstate.isconfirmed, title="Bullish BOS", message="Institutional Flow Pro: Bullish structure break on {{ticker}} at {{close}}")
alertcondition(bearBOS and barstate.isconfirmed, title="Bearish BOS", message="Institutional Flow Pro: Bearish structure break on {{ticker}} at {{close}}")