//@version=5 strategy(“RSI(6) Buy at 30, EMA(34) Sell with Stop Loss”, overlay=true)
// Tetapan parameter rsiPeriod = 6 emaPeriod = 54 buyLevel = 30 positionSize = 0.02
// Mengira RSI dan EMA rsiValue = ta.rsi(close, rsiPeriod) emaValue = ta.ema(close, emaPeriod)
// Syarat pembelian: RSI kurang daripada 30 buySignal = ta.crossunder(rsiValue, buyLevel)
// Syarat jual: harga lebih tinggi daripada EMA 54 sellSignal = close > emaValue
// Mencatat harga pembukaan var float entryPrice = na
// Logik beli: hanya buat lebih if (buySignal and strategy.position_size == 0) strategy.entry(“Buy”, strategy.long, qty=positionSize) entryPrice: = close // Mencatat harga bukaan semasa pembelian
// Stop Loss Logic: Tetapkan Stop Loss kepada 0.5% if (strategy.position_size > 0) stopLossPrice = entryPrice * 0.995 // 0.5% Stop Loss if (close <= stopLossPrice) strategy.close (((“Buy”, comment=“Stop Loss”) // Hentikan kerugian kedudukan sejajar
// Logik penutupan: harga lebih tinggi daripada EMA 54 ketika penutupan if (strategy.position_size > 0 and sellSignal) strategy.close ((“Buy”, comment=“Take Profit”) // mencapai kedudukan terhad