//@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")
Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.