TVC:GOLD   CFDs VÀNG (US$/OZ)
```
//@version=4
strategy("Moving Average Crossover")

// Define moving averages
fastMA = input(title="Fast MA Period", type=input.integer, defval=10)
slowMA = input(title="Slow MA Period", type=input.integer, defval=50)

// Calculate moving averages
fast = sma(close, fastMA)
slow = sma(close, slowMA)

// Set up Buy and Sell conditions
buySignal = crossover(fast, slow)
sellSignal = crossunder(fast, slow)

// Set up stop loss
stopLoss = strategy.position_avg_price * 0.5
takeProfit = strategy.position_avg_price * 2

// Enter Buy or Sell orders
if buySignal
strategy.entry("Buy", strategy.long)
strategy.exit("Stop Loss", "Buy", stop=stopLoss, limit=takeProfit)

if sellSignal
strategy.entry("Sell", strategy.short)
strategy.exit("Stop Loss", "Sell", stop=stopLoss, limit=takeProfit)

// Plot Buy and Sell signals
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, transp=0)
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, transp=0)
```

Ý tưởng liên quan

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.