PROTECTED SOURCE SCRIPT

📊 MERGED: TARA + TREND + SUPER TRIGGER

16
//version=5
indicator("📊 MERGED: TARA + TREND + SUPER TRIGGER", overlay=true)

// === EMAs & VWAP ===
ema5 = ta.ema(close, 5)
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
vwap = ta.vwap

// === Plot EMAs & VWAP ===
plot(ema5, color=color.orange, title="EMA 5")
plot(ema20, color=color.blue, title="EMA 20")
plot(ema50, color=color.red, title="EMA 50")
plot(ema200, color=color.gray, title="EMA 200")
plot(vwap, color=color.purple, title="VWAP")

// ========== LOGIC 1: ⭐ TARA Candle (EMA50 Retest) ==========
emaCrossUp = ta.crossover(ema20, ema50)
emaCrossDown = ta.crossunder(ema20, ema50)

var bool buyCrossoverActive = false
var bool sellCrossoverActive = false

if emaCrossUp
buyCrossoverActive := true
if emaCrossDown
buyCrossoverActive := false
if emaCrossDown
sellCrossoverActive := true
if emaCrossUp
sellCrossoverActive := false

// BUY Retest
var float retestHigh = na
var int retestBar = na
buyRetest = buyCrossoverActive and close < ema50 and high < ema5 and high < ema20 and high < ema50
if buyRetest
retestHigh := high
retestBar := bar_index
buyBreakout_TARA = not na(retestHigh) and bar_index == retestBar + 1 and high > retestHigh and low <= retestHigh and ema5 > ema200 and ema20 > ema200 and ema50 > ema200 and close > ema200
if buyBreakout_TARA
retestHigh := na
retestBar := na

// SELL Retest
var float retestLow = na
var int retestBarSell = na
sellRetest = sellCrossoverActive and close > ema50 and low > ema5 and low > ema20 and low > ema50
if sellRetest
retestLow := low
retestBarSell := bar_index
sellBreakdown = not na(retestLow) and bar_index == retestBarSell + 1 and low < retestLow and high >= retestLow and ema5 < ema200 and ema20 < ema200 and ema50 < ema200 and close < ema200
if sellBreakdown
retestLow := na
retestBarSell := na

plotshape(buyBreakout_TARA, title="⭐ BUY TARA CANDLE", style=shape.labelup, location=location.belowbar, color=color.rgb(243, 240, 46), text="⭐ BUY TARA CANDLE", textcolor=color.rgb(248, 11, 11), size=size.normal, offset=-1)
plotshape(sellBreakdown, title="⭐ SELL TARA CANDLE", style=shape.labeldown, location=location.abovebar, color=color.rgb(134, 6, 6), text="⭐ SELL TARA CANDLE", textcolor=color.rgb(233, 247, 38), size=size.normal, offset=-1)

// === ALERTS ===
alertcondition(buyBreakout_TARA, title="⭐ BUY Alert", message="⭐ BUY TARA CANDLE 🔔 on {{ticker}} at {{close}}")
alertcondition(sellBreakdown, title="⭐ SELL Alert", message="⭐ SELL TARA CANDLE 🔔 on {{ticker}} at {{close}}")

// ========== LOGIC 2: Trend Touches at EMA50/VWAP ==========

bullishStructure = ema5 > ema20 and ema20 > ema50 and ema5 > ema200 and ema20 > ema200 and ema50 > ema200 and close > ema200
bearishStructure = ema5 < ema20 and ema20 < ema50 and ema5 < ema200 and ema20 < ema200 and ema50 < ema200 and close < ema200
trendBreakBull = ta.crossunder(ema20, ema50)
trendBreakBear = ta.crossover(ema20, ema50)

var bool bullishActive = false
var bool bearishActive = false
if bullishStructure
bullishActive := true
if trendBreakBull
bullishActive := false
if bearishStructure
bearishActive := true
if trendBreakBear
bearishActive := false

dist = 0.002

var bool canBuyEMA50 = true
if (low - ema50) / ema50 > dist
canBuyEMA50 := true
ema50TouchFromAbove = close[1] > ema50 and low <= ema50
buySignal_EMA50 = bullishActive and ema50TouchFromAbove and canBuyEMA50
if buySignal_EMA50
canBuyEMA50 := false

var bool canBuyVWAP = true
if (low - vwap) / vwap > dist
canBuyVWAP := true
vwapTouchFromAbove = close[1] > vwap and low <= vwap
buySignal_VWAP = bullishActive and vwapTouchFromAbove and canBuyVWAP and vwap < ema20
if buySignal_VWAP
canBuyVWAP := false

var bool canSellEMA50 = true
if (ema50 - high) / ema50 > dist
canSellEMA50 := true
ema50TouchFromBelow = close[1] < ema50 and high >= ema50
sellSignal_EMA50 = bearishActive and ema50TouchFromBelow and canSellEMA50
if sellSignal_EMA50
canSellEMA50 := false

var bool canSellVWAP = true
if (vwap - high) / vwap > dist
canSellVWAP := true
vwapTouchFromBelow = close[1] < vwap and high >= vwap
sellSignal_VWAP = bearishActive and vwapTouchFromBelow and canSellVWAP and vwap > ema20
if sellSignal_VWAP
canSellVWAP := false

plotshape(buySignal_EMA50, title="BUY EMA50", location=location.belowbar, style=shape.labelup, color=color.green, text="BUY")
plotshape(buySignal_VWAP, title="BUY VWAP", location=location.belowbar, style=shape.labelup, color=color.yellow, text="BUY")
plotshape(sellSignal_EMA50, title="SELL EMA50", location=location.abovebar, style=shape.labeldown, color=color.red, text="SELL")
plotshape(sellSignal_VWAP, title="SELL VWAP", location=location.abovebar, style=shape.labeldown, color=color.yellow, text="SELL")

alertcondition(buySignal_EMA50, title="Buy on EMA50", message="BUY Signal: EMA50 touch from above (bullish trend)")
alertcondition(buySignal_VWAP, title="Buy on VWAP", message="BUY Signal: VWAP touch from above (VWAP below EMA20)")
alertcondition(sellSignal_EMA50, title="Sell on EMA50", message="SELL Signal: EMA50 touch from below (bearish trend)")
alertcondition(sellSignal_VWAP, title="Sell on VWAP", message="SELL Signal: VWAP touch from below (VWAP above EMA20)")

// ========== LOGIC 3: SUPER TRIGGER BUY & SELL ==========

bullishCross = ta.crossover(ema20, ema50)
bearishCross = ta.crossunder(ema20, ema50)

var bool validBuyCrossover = false
var bool priceWentAboveEMA200 = false
var bool ema20Above200 = false
if bullishCross
validBuyCrossover := true
if bearishCross
validBuyCrossover := false
if validBuyCrossover and close > ema200
priceWentAboveEMA200 := true
if bearishCross
priceWentAboveEMA200 := false
if validBuyCrossover and ema20 > ema200
ema20Above200 := true
if bearishCross
ema20Above200 := false

var bool validSellCrossdown = false
var bool priceWentBelowEMA200 = false
var bool ema20Below200 = false
if bearishCross
validSellCrossdown := true
if bullishCross
validSellCrossdown := false
if validSellCrossdown and close < ema200
priceWentBelowEMA200 := true
if bullishCross
priceWentBelowEMA200 := false
if validSellCrossdown and ema20 < ema200
ema20Below200 := true
if bullishCross
ema20Below200 := false

buySetupCandle = close[1] < ema5[1] and close[1] < ema20[1] and close[1] < ema50[1] and close[1] < ema200[1]
buyHighClean = high[1] < ema5[1] and high[1] < ema20[1] and high[1] < ema50[1] and high[1] < ema200[1]
validBuySetup = buySetupCandle and buyHighClean
buyBreakout_SUPER = high > high[1]

sellSetupCandle = close[1] > ema5[1] and close[1] > ema20[1] and close[1] > ema50[1] and close[1] > ema200[1]
sellLowClean = low[1] > ema5[1] and low[1] > ema20[1] and low[1] > ema50[1] and low[1] > ema200[1]
validSellSetup = sellSetupCandle and sellLowClean
sellBreakout_SUPER = low < low[1]

var int lastSignalBar = na
cooldownPassed = na(lastSignalBar) or (bar_index - lastSignalBar > 2)

superBuy = (validBuyCrossover and priceWentAboveEMA200 and ema20Above200 and validBuySetup and buyBreakout_SUPER and cooldownPassed)
superSell = (validSellCrossdown and priceWentBelowEMA200 and ema20Below200 and validSellSetup and sellBreakout_SUPER and cooldownPassed)
if superBuy or superSell
lastSignalBar := bar_index

buyEntry = high
buySL = low[1]
buyRisk = buyEntry - buySL
buyTP = buyEntry + (buyRisk * 1.5)

sellEntry = low
sellSL = high[1]
sellRisk = sellSL - sellEntry
sellTP = sellEntry - (sellRisk * 2.0)

if superBuy
label.new(bar_index, low - buyRisk * 0.5, "SUPER TRIGGER", style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)
if superSell
label.new(bar_index, high + sellRisk * 0.5, "SUPER TRIGGER", style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)

alertcondition(superBuy, title="BUY SUPER TRIGGER", message="🟢 SUPER TRIGGER BUY | Entry: {{high}} | SL: {{low[1]}} | Target: {{high + ((high - low[1]) * 1.5)}}")
alertcondition(superSell, title="SELL SUPER TRIGGER", message="🔴 SUPER TRIGGER SELL | Entry: {{low}} | SL: {{high[1]}} | Target: {{low - ((high[1] - low) * 2.0)}}")

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.