Smart money concept Pro [SMC] | Pine Script Indicator

PROTRADER9 · study · 89 行 · 点赞 527 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PROTRADER9
 
//@version=6
indicator("Smart Money Signals [SMC]", overlay=true, max_labels_count=300, max_lines_count=300)
 
// ───── SETTINGS ─────
swingLen = input.int(5, "Swing Length", minval=2)
emaLen = input.int(50, "Trend EMA Length", minval=1)
showTrend = input.bool(true, "Show Trend EMA")
showSweeps = input.bool(true, "Show Liquidity Sweeps")
showStructure = input.bool(true, "Show BOS / CHoCH")
showSignals = input.bool(true, "Show BUY / SELL Signals")
 
// ───── TREND ─────
emaTrend = ta.ema(close, emaLen)
plot(showTrend ? emaTrend : na, "Trend EMA", color=color.orange, linewidth=2)
 
bullTrend = close > emaTrend
bearTrend = close < emaTrend
 
// ───── SWING DETECTION ─────
pivotHigh = ta.pivothigh(high, swingLen, swingLen)
pivotLow = ta.pivotlow(low, swingLen, swingLen)
 
var float lastHigh = na
var float lastLow = na
var bool highBroken = false
var bool lowBroken = false
var int marketTrend = 0
 
if not na(pivotHigh)
    lastHigh := pivotHigh
    highBroken := false
 
if not na(pivotLow)
    lastLow := pivotLow
    lowBroken := false
 
// ───── MARKET STRUCTURE ─────
bullBreak = not na(lastHigh) and close > lastHigh and not highBroken
bearBreak = not na(lastLow) and close < lastLow and not lowBroken
 
bullChoch = bullBreak and marketTrend == -1
bearChoch = bearBreak and marketTrend == 1
 
bullBos = bullBreak and marketTrend != -1
bearBos = bearBreak and marketTrend != 1
 
if bullBreak
    highBroken := true
    marketTrend := 1
 
if bearBreak
    lowBroken := true
    marketTrend := -1
 
if showStructure and bullBreak and barstate.isconfirmed
    label.new(bar_index, high, bullChoch ? "CHoCH ↑" : "BOS ↑", style=label.style_label_down, color=color.green, textcolor=color.white, size=size.tiny)
 
if showStructure and bearBreak and barstate.isconfirmed
    label.new(bar_index, low, bearChoch ? "CHoCH ↓" : "BOS ↓", style=label.style_label_up, color=color.red, textcolor=color.white, size=size.tiny)
 
// ───── LIQUIDITY SWEEPS ─────
bullSweep = not na(lastLow) and low < lastLow and close > lastLow
bearSweep = not na(lastHigh) and high > lastHigh and close < lastHigh
 
confirmedBullSweep = bullSweep and barstate.isconfirmed
confirmedBearSweep = bearSweep and barstate.isconfirmed
 
plotshape(showSweeps and confirmedBullSweep, title="Bullish Liquidity Sweep", text="SWEEP ↑", style=shape.labelup, location=location.belowbar, color=color.teal, textcolor=color.white, size=size.tiny)
 
plotshape(showSweeps and confirmedBearSweep, title="Bearish Liquidity Sweep", text="SWEEP ↓", style=shape.labeldown, location=location.abovebar, color=color.maroon, textcolor=color.white, size=size.tiny)
 
// ───── BUY / SELL SIGNALS ─────
buySignal = confirmedBullSweep and bullTrend
sellSignal = confirmedBearSweep and bearTrend
 
plotshape(showSignals and buySignal, title="SMC BUY", text="BUY", style=shape.labelup, location=location.belowbar, color=color.lime, textcolor=color.black, size=size.small)
 
plotshape(showSignals and sellSignal, title="SMC SELL", text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
 
// ───── ALERTS ─────
alertcondition(buySignal, title="SMC BUY Alert", message="Smart Money Signals BUY: {{ticker}} at {{close}}")
alertcondition(sellSignal, title="SMC SELL Alert", message="Smart Money Signals SELL: {{ticker}} at {{close}}")
alertcondition(confirmedBullSweep, title="Bullish Liquidity Sweep", message="Bullish liquidity sweep: {{ticker}} at {{close}}")
alertcondition(confirmedBearSweep, title="Bearish Liquidity Sweep", message="Bearish liquidity sweep: {{ticker}} at {{close}}")
alertcondition(bullChoch and barstate.isconfirmed, title="Bullish CHoCH", message="Bullish CHoCH: {{ticker}}")
alertcondition(bearChoch and barstate.isconfirmed, title="Bearish CHoCH", message="Bearish CHoCH: {{ticker}}")

← 返回列表