ICT Turtle Soup Ultimate V2

MrWoof888 · study · 116 行 · 点赞 331 · TradingView 原页

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

Pine Script

//@version=6
indicator("ICT Turtle Soup Ultimate V2", overlay=true)
 
// === INPUTS ===
i_swingLookback = input.int(5, "Swing Lookback", minval=1)
i_maPeriod = input.int(50, "MA Period")
i_useTrendFilter = input.bool(true, "Use Trend Filter")
i_useConfirmation = input.bool(false, "Require Confirmation Bar")
i_instantSignal = input.bool(true, "Allow Instant TS Signal")
i_enableWickTrapMode = input.bool(true, "Enable Wick Trap Mode")
i_showLabels = input.bool(true, "Show Labels")
i_showSwings = input.bool(true, "Show Swing Markers")
i_showBgColor = input.bool(true, "Show Signal Background")
i_labelTextSize = input.string("small", "Label Size", options=["tiny", "small", "normal", "large", "huge"])
i_bullColor = input.color(color.new(color.green, 50), "Bullish Color")
i_bearColor = input.color(color.new(color.red, 50), "Bearish Color")
i_minSwingDistance = input.float(0.5, "Minimum Swing Distance (%)", tooltip="Filter out small swing highs/lows if they are too close to each other.")
 
// Kill Zone Inputs
i_enableKillZone = input.bool(true, "Enable Kill Zone")
i_killZoneType = input.string("New York AM", "Kill Zone", options=["London", "New York AM", "Custom"])
i_customSession = input.session("0800-1100:1234567", "Custom Session")
 
// MTF FVG Inputs (Confidence Boost)
i_enableMTF = input.bool(true, "Enable MTF FVG Confluence")
i_fvgTF = input.timeframe("60", "HTF for FVG")
i_fvgLookback = input.int(20, "FVG Lookback")
 
// === CALCULATIONS ===
ma = ta.sma(close, i_maPeriod)
plot(ma, color=color.red, title="MA", linewidth=2)  // RED LINE FOR MA
 
atr = ta.atr(14)
buffer = atr * 0.5
 
// Price range threshold for filtering minor swings
minDist = i_minSwingDistance / 100 * close
 
isSwingHigh = high[i_swingLookback] > high[i_swingLookback + 1] and high[i_swingLookback] > high[i_swingLookback - 1] and math.abs(high[i_swingLookback] - high[i_swingLookback + 1]) > minDist
isSwingLow = low[i_swingLookback] < low[i_swingLookback + 1] and low[i_swingLookback] < low[i_swingLookback - 1] and math.abs(low[i_swingLookback] - low[i_swingLookback + 1]) > minDist
 
var float prevHigh = na
var float prevLow = na
if isSwingHigh
    prevHigh := high[i_swingLookback]
if isSwingLow
    prevLow := low[i_swingLookback]
 
wickBear = i_enableWickTrapMode and not na(prevHigh) and high > prevHigh and close < prevHigh and (high - close) > math.abs(open - close)
wickBull = i_enableWickTrapMode and not na(prevLow) and low < prevLow and close > prevLow and (close - low) > math.abs(open - close)
 
bearTS = (not na(prevHigh) and high > prevHigh and close < prevHigh) or wickBear
bullTS = (not na(prevLow) and low < prevLow and close > prevLow) or wickBull
 
bearSignal = bearTS and (not i_useTrendFilter or close < ma + buffer)
bullSignal = bullTS and (not i_useTrendFilter or close > ma - buffer)
 
bearConfirmed = (i_useConfirmation and bearSignal[1] and close > open[1]) or (i_instantSignal and bearSignal)
bullConfirmed = (i_useConfirmation and bullSignal[1] and close < open[1]) or (i_instantSignal and bullSignal)
 
getKillZone() =>
    var string session = i_killZoneType == "London" ? "0200-0500:1234567" :
                         i_killZoneType == "New York AM" ? "0800-1100:1234567" :
                         i_customSession
    inSession = time(timeframe.period, session, "America/New_York")
    not na(inSession)
 
inKillZone = not i_enableKillZone or getKillZone()
 
fvgBullish(htfHigh, htfLow, htfClose) =>
    htfLow[2] > htfHigh and htfClose <= htfLow[2] and htfClose >= htfHigh
fvgBearish(htfHigh, htfLow, htfClose) =>
    htfHigh[2] < htfLow and htfClose >= htfHigh[2] and htfClose <= htfLow
 
htfHigh = request.security(syminfo.tickerid, i_fvgTF, high)
htfLow = request.security(syminfo.tickerid, i_fvgTF, low)
htfClose = request.security(syminfo.tickerid, i_fvgTF, close)
 
isFvgBullish = fvgBullish(htfHigh, htfLow, htfClose)
isFvgBearish = fvgBearish(htfHigh, htfLow, htfClose)
 
var float fvgTop = na
var float fvgBottom = na
if isFvgBullish
    fvgTop := htfLow[2], fvgBottom := htfHigh
if isFvgBearish
    fvgTop := htfLow, fvgBottom := htfHigh[2]
 
priceInsideFvg = not na(fvgTop) and not na(fvgBottom) and close <= fvgTop and close >= fvgBottom
mtfConfluenceOK = not i_enableMTF or priceInsideFvg
 
bearFinal = bearConfirmed and inKillZone and mtfConfluenceOK
bullFinal = bullConfirmed and inKillZone and mtfConfluenceOK
 
bearRevDist = bearFinal ? (high - close) : na
bullRevDist = bullFinal ? (close - low) : na
 
if i_showSwings
    if isSwingHigh
        label.new(bar_index[i_swingLookback], high[i_swingLookback], "SH", style=label.style_label_down, color=color.blue, textcolor=color.white, size=size.tiny)
    if isSwingLow
        label.new(bar_index[i_swingLookback], low[i_swingLookback], "SL", style=label.style_label_up, color=color.blue, textcolor=color.white, size=size.tiny)
 
plotshape(bullFinal, location=location.belowbar, style=shape.triangleup, color=i_bullColor, size=size.small, title="Bullish TS", text="🐢🔺")
plotshape(bearFinal, location=location.abovebar, style=shape.triangledown, color=i_bearColor, size=size.small, title="Bearish TS", text="🐢🔻")
 
bgcolor(i_showBgColor and bullFinal ? color.new(i_bullColor, 90) : i_showBgColor and bearFinal ? color.new(i_bearColor, 90) : na)
 
if i_showLabels
    if bearFinal
        label.new(bar_index, high, "Bearish TS\nRev: " + str.tostring(bearRevDist, "#.##") + " pts", style=label.style_label_down, color=i_bearColor, textcolor=color.white, size=i_labelTextSize)
    if bullFinal
        label.new(bar_index, low, "Bullish TS\nRev: " + str.tostring(bullRevDist, "#.##") + " pts", style=label.style_label_up, color=i_bullColor, textcolor=color.white, size=i_labelTextSize)
 
alertcondition(bearFinal, title="Bearish Turtle Soup", message="Bearish TS Signal")
alertcondition(bullFinal, title="Bullish Turtle Soup", message="Bullish TS Signal")

← 返回列表