//@version=6
// Gold Futures (GC) / XAUUSD Strategy
// github.com/trugurpala/pinescriptv6 — Author: Ugur Pala
//
// TR: Semboller: COMEX:GC1! (futures) / OANDA:XAUUSD (spot CFD)
// EN: Symbols: COMEX:GC1! (futures) / OANDA:XAUUSD (spot CFD)
//
// Seans / Session: 08:20–13:30 ET (en aktif) / 24h işlem
// Önemli: Çarşamba EIA raporu, Fed kararları volatiliteyi artırır
// Note: Wednesday EIA reports and Fed decisions increase volatility
strategy("Gold GC/XAUUSD Strategy [trugurpala]",
overlay = true,
initial_capital = 10000,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 5,
commission_type = strategy.commission.percent,
commission_value = 0.03,
slippage = 2)
// ── Inputs ───────────────────────────────────────────────────────────────────
int fastLen = input.int(9, "Fast EMA", minval=1)
int slowLen = input.int(21, "Slow EMA", minval=1)
int atrLen = input.int(14, "ATR", minval=1)
float slMult = input.float(1.5, "SL Mult", step=0.1)
float tpMult = input.float(2.5, "TP Mult", step=0.1)
bool longOnly = input.bool(true, "Long Only (Gold trend is up)")
// ── Hesaplamalar ──────────────────────────────────────────────────────────────
float fastEma = ta.ema(close, fastLen)
float slowEma = ta.ema(close, slowLen)
float atrVal = ta.atr(atrLen)
float trendEma = ta.ema(close, 200)
bool bullCross = ta.crossover(fastEma, slowEma) and close > trendEma
bool bearCross = ta.crossunder(fastEma, slowEma) and close < trendEma
// ── Entries ──────────────────────────────────────────────────────────────────
if bullCross
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long",
stop = close - slMult * atrVal,
limit = close + tpMult * atrVal)
if bearCross and not longOnly
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short",
stop = close + slMult * atrVal,
limit = close - tpMult * atrVal)
// ── Visuals ──────────────────────────────────────────────────────────────────
plot(fastEma, "Fast", fastEma > slowEma ? color.green : color.red, linewidth=2)
plot(slowEma, "Slow", fastEma > slowEma ? color.lime : color.orange, linewidth=2)
plot(trendEma, "Trend 200", color.new(color.gray, 40), linewidth=1)
plotshape(bullCross, "Long", shape.triangleup, location.belowbar, color.green)
plotshape(bearCross, "Short", shape.triangledown, location.abovebar, color.red)