OPEN-SOURCE SCRIPT
XAUUSD Scalping System [MACD + EMA + UT Bot + LinReg]

//version=5
indicator("XAUUSD Scalping System [MACD + EMA + UT Bot + LinReg]", overlay=true)
// === INPUTS ===
fastLen = input.int(8, title="MACD Fast Length")
slowLen = input.int(21, title="MACD Slow Length")
signalLen = input.int(5, title="MACD Signal Smoothing")
linregLen = input.int(14, title="Linear Regression Length")
emaLen = input.int(21, title="EMA Length")
atrPeriod = input.int(10, title="UT Bot ATR Period")
atrMultiplier = input.float(2.0, title="UT Bot ATR Multiplier")
// === EMA ===
ema = ta.ema(close, emaLen)
plot(ema, title="21 EMA", color=color.orange, linewidth=1)
// === MACD ===
macdLine = ta.ema(close, fastLen) - ta.ema(close, slowLen)
signalLine = ta.ema(macdLine, signalLen)
hist = macdLine - signalLine
macdBull = hist > 0 and hist > hist[1]
macdBear = hist < 0 and hist < hist[1]
// === Linear Regression ===
linreg = ta.linreg(close, linregLen, 0)
bullCandle = close > linreg
bearCandle = close < linreg
barcolor(bullCandle ? color.new(color.green, 40) : bearCandle ? color.new(color.red, 40) : na)
// === UT Bot ===
atr = ta.atr(atrPeriod)
upperBand = close + atr * atrMultiplier
lowerBand = close - atr * atrMultiplier
var float trend = na
trend := na(trend[1]) ? 1 : trend[1]
trend := close > upperBand ? 1 : close < lowerBand ? -1 : trend[1]
buyUT = ta.crossover(trend, 0)
sellUT = ta.crossunder(trend, 0)
// === ENTRY CONDITIONS ===
longCondition = buyUT and bullCandle and macdBull and close > ema
shortCondition = sellUT and bearCandle and macdBear and close < ema
plotshape(longCondition, title="BUY Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(shortCondition, title="SELL Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)
bgcolor(longCondition ? color.new(color.green, 85) : shortCondition ? color.new(color.red, 85) : na, title="Signal Background")
// === Alerts ===
alertcondition(longCondition, title="BUY Alert", message="XAUUSD BUY setup triggered!")
alertcondition(shortCondition, title="SELL Alert", message="XAUUSD SELL setup triggered!")
indicator("XAUUSD Scalping System [MACD + EMA + UT Bot + LinReg]", overlay=true)
// === INPUTS ===
fastLen = input.int(8, title="MACD Fast Length")
slowLen = input.int(21, title="MACD Slow Length")
signalLen = input.int(5, title="MACD Signal Smoothing")
linregLen = input.int(14, title="Linear Regression Length")
emaLen = input.int(21, title="EMA Length")
atrPeriod = input.int(10, title="UT Bot ATR Period")
atrMultiplier = input.float(2.0, title="UT Bot ATR Multiplier")
// === EMA ===
ema = ta.ema(close, emaLen)
plot(ema, title="21 EMA", color=color.orange, linewidth=1)
// === MACD ===
macdLine = ta.ema(close, fastLen) - ta.ema(close, slowLen)
signalLine = ta.ema(macdLine, signalLen)
hist = macdLine - signalLine
macdBull = hist > 0 and hist > hist[1]
macdBear = hist < 0 and hist < hist[1]
// === Linear Regression ===
linreg = ta.linreg(close, linregLen, 0)
bullCandle = close > linreg
bearCandle = close < linreg
barcolor(bullCandle ? color.new(color.green, 40) : bearCandle ? color.new(color.red, 40) : na)
// === UT Bot ===
atr = ta.atr(atrPeriod)
upperBand = close + atr * atrMultiplier
lowerBand = close - atr * atrMultiplier
var float trend = na
trend := na(trend[1]) ? 1 : trend[1]
trend := close > upperBand ? 1 : close < lowerBand ? -1 : trend[1]
buyUT = ta.crossover(trend, 0)
sellUT = ta.crossunder(trend, 0)
// === ENTRY CONDITIONS ===
longCondition = buyUT and bullCandle and macdBull and close > ema
shortCondition = sellUT and bearCandle and macdBear and close < ema
plotshape(longCondition, title="BUY Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(shortCondition, title="SELL Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)
bgcolor(longCondition ? color.new(color.green, 85) : shortCondition ? color.new(color.red, 85) : na, title="Signal Background")
// === Alerts ===
alertcondition(longCondition, title="BUY Alert", message="XAUUSD BUY setup triggered!")
alertcondition(shortCondition, title="SELL Alert", message="XAUUSD SELL setup triggered!")
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.