XAUUSD Pro Swing Strategy (RR 1:2) by mail2mangalnath
By version
Performance Metrics
- Author: version
- Symbol: OANDA:XAUUSD
- Timeframe: 5 minutes
- Net P&L: +6.07 USD (+0.06%)
- Win Rate: 37.9%
- Profit Factor: 1.453
- Max Drawdown: 2.15 USD (0.02%)
- Total Trades: 95
Description
//version=5strategy("XAUUSD Pro Swing Strategy (RR 1:2)", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=2)// ===== INPUTS =====emaFastLen = input.int(20, "Fast EMA")emaMidLen = input.int(50, "Mid EMA")emaTrendLen = input.int(200, "Trend EMA (HTF)")rsiLen = input.int(14, "RSI Length")atrLen = input.int(14, "ATR Length")atrSLMult = input.float(1.5, "ATR SL Multiplier")rr = input.float(2.0, "Risk Reward")// ===== HTF TREND =====htfEMA = request.security(syminfo.tickerid, "D", ta.ema(close, emaTrendLen))// ===== INDICATORS =====emaFast = ta.ema(close, emaFastLen)emaMid = ta.ema(close, emaMidLen)rsi = ta.rsi(close, rsiLen)atr = ta.atr(atrLen)// ===== TREND CONDITIONS =====bullTrend = close > htfEMA and emaFast > emaMidbearTrend = close 55sellCond = bearTrend and ta.crossunder(emaFast, emaMid) and rsi < 45// ===== SL & TP =====buySL = close - atr * atrSLMultbuyTP = close + (atr * atrSLMult * rr)sellSL = close + atr * atrSLMultsellTP = close - (atr * atrSLMult * rr)// ===== ORDERS =====if buyCond strategy.entry("BUY", strategy.long) strategy.exit("BUY EXIT", "BUY", stop=buySL, limit=buyTP)if sellCond strategy.entry("SELL", strategy.short) strategy.exit("SELL EXIT", "SELL", stop=sellSL, limit=sellTP)// ===== PLOTS =====plot(emaFast, color=color.orange)plot(emaMid, color=color.blue)plot(htfEMA, color=color.red, linewidth=2)plotshape(buyCond, style=shape.labelup, text="BUY", color=color.green, location=location.belowbar)plotshape(sellCond, style=shape.labeldown, text="SELL", color=color.red, location=location.abovebar)