//@version=5
strategy("Gold Trading Strategy", overlay=true)

// Input parameters
k_period = input(14, title="Stochastic %K Period")
d_period = input(3, title="Stochastic %D Period")
smooth_k = input(3, title="Stochastic Smoothing")

sma_50 = ta.sma(close, 50)
sma_200 = ta.sma(close, 200)

= ta.stoch(k_period, d_period, smooth_k)

// Buy condition
buy_condition = ta.crossover(k, d) and k < 20 and close > sma_50 and close > sma_200
if (buy_condition)
strategy.entry("Buy", strategy.long)

// Sell condition
sell_condition = ta.crossunder(k, d) and k > 80 and close < sma_50 and close < sma_200
if (sell_condition)
strategy.entry("Sell", strategy.short)

// Plotting
plot(sma_50, color=color.blue, title="SMA 50")
plot(sma_200, color=color.red, title="SMA 200")
Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.