OPEN-SOURCE SCRIPT

XAUUSD 10-Minute Strategy

This XAUUSD 10-Minute Strategy is designed for trading Gold vs. USD on a 10-minute timeframe. By combining multiple technical indicators (MACD, RSI, Bollinger Bands, and ATR), the strategy effectively captures both trend-following and reversal opportunities, with adaptive risk management for varying market volatility. This approach balances high-probability entries with robust volatility management, making it suitable for traders seeking to optimise entries during significant price movements and reversals.

Key Components and Logic:
MACD (12, 26, 9):
  • Generates buy signals on MACD Line crossovers above the Signal Line and sell signals on crossovers below the Signal Line, helping to capture momentum shifts.

RSI (14):
  • Utilizes oversold (below 35) and overbought (above 65) levels as a secondary filter to validate entries and avoid overextended price zones.

Bollinger Bands (20, 2):
  • Uses upper and lower Bollinger Bands to identify potential overbought and oversold conditions, aiming to enter long trades near the lower band and short trades near the upper band.

ATR-Based Stop Loss and Take Profit:
  • Stop Loss and Take Profit levels are dynamically set as multiples of ATR (3x for stop loss, 5x for take profit), ensuring flexibility with market volatility to optimise exit points.


Entry & Exit Conditions:
Buy Entry: Triggered when any of the following conditions are met:
  • MACD Line crosses above the Signal Line
  • RSI is oversold
  • Price drops below the lower Bollinger Band

Sell Entry: Triggered when any of the following conditions are met:
  • MACD Line crosses below the Signal Line
  • RSI is overbought
  • Price moves above the upper Bollinger Band

Exit Strategy: Trades are closed based on opposing entry signals, with adaptive spread adjustments for realistic exit points.

Backtesting Configuration & Results:
  • Backtesting Period: July 21, 2024, to October 30, 2024
  • Symbol Info: XAUUSD, 10-minute timeframe, OANDA data source
  • Backtesting Capital: Initial capital of $700, with each trade set to 10 contracts (equivalent to approximately 0.1 lots based on the broker’s contract size for gold).


Users should confirm their broker's contract size for gold, as this may differ. This script uses 10 contracts for backtesting purposes, aligned with 0.1 lots on brokers offering a 100-contract specification.

Key Backtesting Performance Metrics:

  • Net Profit: $4,733.90 USD (676.27% increase)
  • Total Closed Trades: 526
  • Win Rate: 53.99%
  • Profit Factor: 1.44 (1.96 for Long trades, 1.14 for Short trades)
  • Max Drawdown: $819.75 USD (56.33% of equity)
  • Sharpe Ratio: 1.726
  • Average Trade: $9.00 USD (0.04% of equity per trade)


This backtest reflects realistic conditions, with a spread adjustment of 38 points and no slippage or commission applied. The settings aim to simulate typical retail trading conditions. However, please adjust the initial capital, contract size, and other settings based on your account specifics for best results.

Usage:
This strategy is tuned specifically for XAUUSD on a 10-minute timeframe, ideal for both trend-following and reversal trades. The ATR-based stop loss and take profit levels adapt dynamically to market volatility, optimising entries and exits in varied conditions. To backtest this script accurately, ensure your broker’s contract specifications for gold align with the parameters used in this strategy.
Average True Range (ATR)Moving Average Convergence / Divergence (MACD)Relative Strength Index (RSI)smuk90XAUUSD

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?

Wyłączenie odpowiedzialności