TEVV12 + Target Finder SMC Edition | Albert Setups

AlbertSetups · study · 212 行 · 点赞 234 · TradingView 原页

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

Pine Script

//@version=6
indicator("TEVV12 + Target Finder SMC Edition | Albert Setups", overlay=true, max_labels_count=150, max_lines_count=40)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1. EMA TREND FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupEMA = "EMA Trend Filter"
fastLen = input.int(50, "Fast EMA Length", minval=1, group=groupEMA)
slowLen = input.int(200, "Slow EMA Length", minval=1, group=groupEMA)
showEMA = input.bool(false, "Show EMA Lines", group=groupEMA)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 2. TEVV12-STYLE CONFIRMATION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupTEVV = "TEVV12-Style Confirmation"
rsiLen = input.int(14, "RSI Length", minval=2, group=groupTEVV)
buyRSI = input.int(52, "Minimum BUY RSI", minval=1, maxval=99, group=groupTEVV)
sellRSI = input.int(48, "Maximum SELL RSI", minval=1, maxval=99, group=groupTEVV)
useCandle = input.bool(true, "Require Candle Confirmation", group=groupTEVV)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 3. SMART MONEY CONCEPTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupSMC = "SMC & Liquidity"
pivotLen = input.int(5, "Swing Strength", minval=2, maxval=20, group=groupSMC)
signalMode = input.string("Sweep or BOS", "SMC Signal Mode", options=["Sweep Only", "BOS Only", "Sweep or BOS"], group=groupSMC)
showBOS = input.bool(true, "Show BOS Labels", group=groupSMC)
showSweeps = input.bool(true, "Show Liquidity Sweeps", group=groupSMC)
showSR = input.bool(true, "Show Swing Support / Resistance", group=groupSMC)
cooldown = input.int(5, "Bars Between Signals", minval=0, maxval=100, group=groupSMC)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4. TARGET FINDER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupTargets = "Target Finder & Risk"
atrLen = input.int(14, "ATR Length", minval=1, group=groupTargets)
tp1Mult = input.float(1.0, "Target 1 ATR Multiplier", minval=0.25, step=0.25, group=groupTargets)
tp2Mult = input.float(2.0, "Target 2 ATR Multiplier", minval=0.5, step=0.25, group=groupTargets)
slMult = input.float(1.0, "Stop Loss ATR Multiplier", minval=0.25, step=0.25, group=groupTargets)
showTargets = input.bool(true, "Show Latest Trade Levels", group=groupTargets)
lineBars = input.int(25, "Target Line Length", minval=5, maxval=100, group=groupTargets)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5. TREND & MOMENTUM
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
rsiValue = ta.rsi(close, rsiLen)
atrValue = ta.atr(atrLen)
 
bullTrend = fastEMA > slowEMA and close > fastEMA
bearTrend = fastEMA < slowEMA and close < fastEMA
 
plot(showEMA ? fastEMA : na, "Fast EMA", color=color.orange, linewidth=1)
plot(showEMA ? slowEMA : na, "Slow EMA", color=color.blue, linewidth=2)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6. SWING STRUCTURE & LIQUIDITY
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow = ta.pivotlow(low, pivotLen, pivotLen)
 
var float swingHigh = na
var float swingLow = na
 
if not na(pivotHigh)
    swingHigh := pivotHigh
 
if not na(pivotLow)
    swingLow := pivotLow
 
plot(showSR ? swingHigh : na, "Swing Resistance", color=color.new(color.red, 25), linewidth=1, style=plot.style_stepline)
plot(showSR ? swingLow : na, "Swing Support", color=color.new(color.lime, 25), linewidth=1, style=plot.style_stepline)
 
// BOS: confirmed candle closes across the last confirmed swing.
bullBOS = barstate.isconfirmed and not na(swingHigh) and ta.crossover(close, swingHigh)
bearBOS = barstate.isconfirmed and not na(swingLow) and ta.crossunder(close, swingLow)
 
// Sweep: price pierces a swing and closes back across the level.
bullSweep = barstate.isconfirmed and not na(swingLow) and low < swingLow and close > swingLow
bearSweep = barstate.isconfirmed and not na(swingHigh) and high > swingHigh and close < swingHigh
 
plotshape(showBOS and bullBOS, title="Bullish BOS", text="BOS", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.tiny)
plotshape(showBOS and bearBOS, title="Bearish BOS", text="BOS", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.tiny)
 
plotshape(showSweeps and bullSweep, title="Bullish Sweep", text="SWEEP", style=shape.labelup, location=location.belowbar, color=color.aqua, textcolor=color.black, size=size.tiny)
plotshape(showSweeps and bearSweep, title="Bearish Sweep", text="SWEEP", style=shape.labeldown, location=location.abovebar, color=color.orange, textcolor=color.black, size=size.tiny)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 7. BUY / SELL SIGNAL ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bullSMC = switch signalMode
    "Sweep Only" => bullSweep
    "BOS Only" => bullBOS
    => bullSweep or bullBOS
 
bearSMC = switch signalMode
    "Sweep Only" => bearSweep
    "BOS Only" => bearBOS
    => bearSweep or bearBOS
 
bullCandle = close > open
bearCandle = close < open
 
buySetup = bullTrend and bullSMC and rsiValue >= buyRSI and (not useCandle or bullCandle)
sellSetup = bearTrend and bearSMC and rsiValue <= sellRSI and (not useCandle or bearCandle)
 
var int lastSignalBar = na
signalAllowed = na(lastSignalBar) or bar_index - lastSignalBar > cooldown
 
buySignal = barstate.isconfirmed and buySetup and signalAllowed
sellSignal = barstate.isconfirmed and sellSetup and signalAllowed
 
if buySignal or sellSignal
    lastSignalBar := bar_index
 
plotshape(buySignal, title="TEVV12 SMC BUY", text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)
plotshape(sellSignal, title="TEVV12 SMC SELL", text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 8. TARGET FINDER — ATR LEVELS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var float activeTP1 = na
var float activeTP2 = na
var float activeSL = na
var int activeDirection = 0
var int entryBar = na
var bool tp1Hit = false
var bool tp2Hit = false
var bool slHit = false
var bool tradeActive = false
 
var line tp1Line = na
var line tp2Line = na
var line slLine = na
var label tp1Label = na
var label tp2Label = na
var label slLabel = na
 
if buySignal or sellSignal
    activeDirection := buySignal ? 1 : -1
    entryBar := bar_index
    activeTP1 := close + activeDirection * atrValue * tp1Mult
    activeTP2 := close + activeDirection * atrValue * tp2Mult
    activeSL := close - activeDirection * atrValue * slMult
    tp1Hit := false
    tp2Hit := false
    slHit := false
    tradeActive := not na(atrValue)
 
    if not na(tp1Line)
        line.delete(tp1Line)
    if not na(tp2Line)
        line.delete(tp2Line)
    if not na(slLine)
        line.delete(slLine)
    if not na(tp1Label)
        label.delete(tp1Label)
    if not na(tp2Label)
        label.delete(tp2Label)
    if not na(slLabel)
        label.delete(slLabel)
 
    if showTargets and not na(atrValue)
        tp1Line := line.new(bar_index, activeTP1, bar_index + lineBars, activeTP1, color=color.lime, style=line.style_dashed)
        tp2Line := line.new(bar_index, activeTP2, bar_index + lineBars, activeTP2, color=color.green, width=2)
        slLine := line.new(bar_index, activeSL, bar_index + lineBars, activeSL, color=color.red, style=line.style_dashed, width=2)
 
        tp1Label := label.new(bar_index + lineBars, activeTP1, "TP1", style=label.style_label_left, color=color.lime, textcolor=color.black, size=size.tiny)
        tp2Label := label.new(bar_index + lineBars, activeTP2, "TP2", style=label.style_label_left, color=color.green, textcolor=color.white, size=size.tiny)
        slLabel := label.new(bar_index + lineBars, activeSL, "STOP", style=label.style_label_left, color=color.red, textcolor=color.white, size=size.tiny)
 
// Evaluate hits after the entry candle closes.
// If target and stop are both touched in one candle, stop takes priority.
activeTrade = tradeActive and not na(entryBar) and bar_index > entryBar
 
stopTouched = activeTrade and (activeDirection == 1 ? low <= activeSL : high >= activeSL)
tp1Touched = activeTrade and (activeDirection == 1 ? high >= activeTP1 : low <= activeTP1)
tp2Touched = activeTrade and (activeDirection == 1 ? high >= activeTP2 : low <= activeTP2)
 
stopHitNow = barstate.isconfirmed and stopTouched
tp1HitNow = barstate.isconfirmed and not stopHitNow and not slHit and not tp1Hit and tp1Touched
tp2HitNow = barstate.isconfirmed and not stopHitNow and not slHit and not tp2Hit and tp2Touched
 
if stopHitNow
    slHit := true
    tradeActive := false
    label.new(bar_index, activeSL, "STOP HIT", style=label.style_label_left, color=color.red, textcolor=color.white, size=size.tiny)
 
if tp1HitNow
    tp1Hit := true
    label.new(bar_index, activeTP1, "TP1 HIT", style=label.style_label_left, color=color.green, textcolor=color.white, size=size.tiny)
 
if tp2HitNow
    tp2Hit := true
    tradeActive := false
    label.new(bar_index, activeTP2, "TP2 HIT", style=label.style_label_left, color=color.green, textcolor=color.white, size=size.tiny)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 9. ALERTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
alertcondition(buySignal, title="TEVV12 SMC BUY", message="TEVV12 + Target Finder BUY on {{ticker}} at {{close}}")
alertcondition(sellSignal, title="TEVV12 SMC SELL", message="TEVV12 + Target Finder SELL on {{ticker}} at {{close}}")
 
alertcondition(bullBOS, title="Bullish BOS", message="Bullish BOS on {{ticker}} at {{close}}")
alertcondition(bearBOS, title="Bearish BOS", message="Bearish BOS on {{ticker}} at {{close}}")
alertcondition(bullSweep, title="Bullish Liquidity Sweep", message="Bullish liquidity sweep on {{ticker}} at {{close}}")
alertcondition(bearSweep, title="Bearish Liquidity Sweep", message="Bearish liquidity sweep on {{ticker}} at {{close}}")
 
alertcondition(tp1HitNow, title="Target 1 Hit", message="Target 1 reached on {{ticker}} at {{close}}")
alertcondition(tp2HitNow, title="Target 2 Hit", message="Target 2 reached on {{ticker}} at {{close}}")
alertcondition(stopHitNow, title="Stop Loss Hit", message="Stop-loss level reached on {{ticker}} at {{close}}")

← 返回列表