OPEN-SOURCE SCRIPT

TAK Indicators by Khoa

158
//version=6
indicator("TAK Indicators by Khoa ", overlay=true)

// === EMA ===
ema10 = ta.ema(close, 10)
ema21 = ta.ema(close, 21)
ema50 = ta.ema(close, 50)

plot(ema10, "EMA 10", color=color.green)
plot(ema21, "EMA 21", color=color.orange)
plot(ema50, "EMA 50", color=color.red)

// === Trend check
isUpTrend = ema10 > ema21 and ema21 > ema50
isDownTrend = ema10 < ema21 and ema21 < ema50

// === RSI
rsi = ta.rsi(close, 14)
rsiBull = ta.crossover(rsi, 50)
rsiBear = ta.crossunder(rsi, 50)

// === Confirmation candle
bullCandle = close > open
bearCandle = close < open
priceConfirmBuy = close > ema10 and close > ema21 and bullCandle
priceConfirmSell = close < ema10 and close < ema21 and bearCandle

// === State machine
var bool inLong = false
var bool inShort = false

buySignal = false
sellSignal = false

if isUpTrend and rsiBull and priceConfirmBuy and not inLong
buySignal := true
inLong := true
inShort := false
else
buySignal := false

if isDownTrend and rsiBear and priceConfirmSell and not inShort
sellSignal := true
inShort := true
inLong := false
else
sellSignal := false

// === DÍNH LABEL DỰA THEO GIÁ (KHÔNG BỊ TRƯỢT ZOOM DỌC)
if buySignal
label.new(bar_index, low - (syminfo.mintick * 10), "B", style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)

if sellSignal
label.new(bar_index, high + (syminfo.mintick * 10), "S", style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)

// === Nền trend
bgcolor(isUpTrend ? color.new(color.green, 90) : na)
bgcolor(isDownTrend ? color.new(color.red, 90) : na)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.