Mcd

118
//version=5
indicator("Gold Trading Strategy", overlay=true)

// Input untuk MACD
fastLength = input(12, title="Fast EMA")
slowLength = input(26, title="Slow EMA")
signalSmoothing = input(9, title="Signal Line Smoothing")
src = close

// Menghitung MACD
[macdLine, signalLine, _] = ta.macd(src, fastLength, slowLength, signalSmoothing)

// Input untuk RSI
rsiLength = input(14, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought Level")
rsiOversold = input(30, title="RSI Oversold Level")
rsi = ta.rsi(src, rsiLength)

// Sinyal Buy dan Sell berdasarkan kombinasi MACD dan RSI
buySignal = ta.crossover(macdLine, signalLine) and rsi < rsiOversold
sellSignal = ta.crossunder(macdLine, signalLine) and rsi > rsiOverbought

// Plot sinyal buy/sell pada chart
plotshape(buySignal, color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, text="BUY")
plotshape(sellSignal, color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, text="SELL")

// Plot garis MACD dan Signal Line
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.red, title="Signal Line")

// Plot RSI di bawah chart
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi, color=color.purple, linewidth=2, title="RSI")

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.