//@version=5 strategy(“RSI(6) Buy at 30, EMA(34) Sell with Stop Loss”, overlay=true)
// Pengaturan parameter rsiPeriod = 6 emaPeriod = 54 buyLevel = 30 positionSize = 0.02
// Menghitung RSI dan EMA rsiValue = ta.rsi(close, rsiPeriod) emaValue = ta.ema(close, emaPeriod)
/ Kondisi Pembelian: RSI di bawah 30 buySignal = ta.crossunder(rsiValue, buyLevel)
// Kondisi jual: harga lebih tinggi dari EMA 54 sellSignal = close > emaValue
// Mencatat harga bukaan var float entryPrice = na
// Membeli logika: hanya melakukan lebih banyak if (buySignal and strategy.position_size == 0) strategy.entry(“Buy”, strategy.long, qty=positionSize) entryPrice: = close // Mencatat harga buka posisi saat membeli
// Stop Loss Logic: Set Stop Loss menjadi 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 posisi setara
// Logika posisi terjal: harga lebih tinggi dari EMA 54 saat posisi terjal if (strategy.position_size > 0 and sellSignal) strategy.close ((“Buy”, comment=“Take Profit”) // mencapai posisi terendah